title: Is there a way to dynamically pick a type from interface in typescript
body: <p>as the title says, I tried to dynamically get the type from interface based on the key I receive in a function.</p>
  <p>Example:</p>
  <pre class="lang-js prettyprint-override"><code>interface State {
      foo: boolean;
      bar: string;
      baz: number;
  }
  
  const globalState: State = {
      foo: true,
      bar: 'somethin',
      baz: 42,
  }
  
  const update = (key: keyof State, newValue: /* TYPE ME PLZ */): State =&gt; {
      globalState[key] = newValue;
      return globalState;
  }
  </code></pre>
  <p>Unfortunately, this causes error <code>Type '&lt;INSERTED_TYPE&gt;' is not assignable to type 'never'</code></p>
  <p>The closest I got is something like this <code>State[keyof State]</code>, but is it totally unrelated to the key I receive in the function.</p>
  <p><strong>My question</strong>: Is there a way to get the type of the <code>newValue</code> parameter?</p>
  <p><strong>Bonus question</strong>: Why is the type in the error message <code>never</code>?</p>