title: Cannot assign to type where key only references said type on given object
body: <p>I am currently trying to build a helper method, where I work with string values on an arbitrary object. However, TypeScript can't seem to infer that &quot;key&quot; is only a key that accesses string-only values on the given object.</p>
  <p>Here is what I got as an example so far:</p>
  <pre><code>const obj = {
    foo: '2022-04-02T15:41',
    bar: 42,
    baz: '2022-04-02T15:41',
  }
  
  type StringValues&lt;T&gt; = {
    [key in keyof T]: T[key] extends string ? key : never
  }[keyof T]
  
  const setString = &lt;T, K extends StringValues&lt;T&gt;&gt;(model: T, key: K, value: string) =&gt; {
    // Errors with &quot;Type 'string' is not assignable to type 'T[K]'.(2322)&quot;
    model[key] = value;
  }
  
  setString(obj, 'baz', 'hi')
  </code></pre>
  <p>What am I missing? Thanks in advance!</p>