title: Typescript , How to infer type from another property value?
body: <p>For example, I have an interface with properties: <code>key</code> and <code>value</code>, I want to infer value type by the key.</p>
  <pre class="lang-js prettyprint-override"><code>interface Obj { a: number; b: string }
  
  interface Param&lt;K extends keyof Obj&gt; {
    key: K
    value: Obj[K] // I want to infer this type
  }
  
  const p: Param&lt;keyof Obj&gt; = {
    key: 'a',
    value: '', // typescript can't infer this type, expect number
  }
  
  </code></pre>
  <p>How can I do that ?</p>