title: Typescript: Using typeof with generics
body: <p>I have the following scenario:</p>
  <pre><code>// Some library
  interface Bar&lt;T&gt; {
    something: T
  }
  
  export function foo&lt;T&gt;(b: Bar&lt;T&gt;) {}
  
  // In my code
  function anotherFoo(param1: ???) {
    MyLib.foo(param1);
  }
  </code></pre>
  <p>Where <code>???</code> is my unknown</p>
  <p><code>Bar</code> is not exported, so intuitively I tried:</p>
  <pre><code>type param&lt;T&gt; = Parameters&lt;typeof foo&lt;T&gt;&gt;[0];
  
  function anotherFoo&lt;X&gt;(param1: param&lt;X&gt;) {
    MyLib.foo(param1);
  }
  </code></pre>
  <p>But <code>type</code> definition is illegal.</p>
  <p>When using <code>type param = Parameters&lt;typeof foo&gt;[0];</code>  <code>typeof</code> seems to infer <code>unknown</code>, i.e. <code>Bar&lt;unknown&gt;</code></p>
  <p>What should <code>???</code> be?</p>
  <p>EDIT: My actual scenario</p>
  <pre><code>import { Observable, of } from 'rxjs';
  import { useDispatch, useSelector } from 'react-redux';
  
  type Items = string[];
  interface AppStore {
      items: Items
  }
  
  type SelectFn = Parameters&lt;typeof useSelector&gt;[0];
  
  function useSelectorAsStream&lt;T&gt;(selectFn: SelectFn) {
      const items = useSelector&lt;AppStore, T&gt;(selectFn);
      const obs: Observable&lt;T&gt; = of(items);
      return obs;
  }
  
  function PartialReactComponent() {
      const myItems: Observable&lt;Items&gt; = useSelectorAsStream&lt;Items&gt;(store =&gt; store.items);
  }
  </code></pre>