title: Typescript pick from function argument
body: <p>In TypeScript is there a way for useContext within the following to pick and return the value type from from Provider?</p>
  
  <pre><code>function Provider&lt;Props = {value: number}&gt;(props: Props) { }
  function useContext&lt;Value&gt;(context: Context&lt;Value&gt;): Pick&lt;Value, 'value'&gt; { return 0 }
  </code></pre>
  
  <p>Such that "Consumer" will return the type: number when used as follows </p>
  
  <pre><code>function Consumer&lt;Props&gt;(props: Props) { return useContext(Provider) }
  </code></pre>
  
  <p>...For additional context:</p>
  
  <pre><code>interface Component&lt;Props = {}&gt; { (props: Properties&lt;Props&gt;): Node }
  interface Context&lt;Value&gt; extends Component&lt;{value: Value}&gt; {}
  </code></pre>
  
  <p>Or alternatively, given</p>
  
  <pre><code>function Provider({value, children}: {value: string, children: any}) {
    return h(Context, {value: 'value'}, children)
  }
  
  const value = useContext(Provider)
  </code></pre>
  
  <p>How would one attribute the constant "value" to the "value" found in the object {value: 'value'} assuming that the function "h" returns an interface:</p>
  
  <pre><code>interface {type: Context, props: {value: 'value}, children: children}
  </code></pre>
  
  <p>I've tried to Pick, props> where Type is "Provider" then Pick from the result of that Pick, props>, 'value'>.</p>
  
  <p>That however didn't seem to work.</p>