title: TypeScript how to create a generic type alias for a generic function?
body: <p>Given a typed generic function, I want to create a generic alias for that function, but it seems I can't. In other words, this doesn't work:</p>
  <pre><code>// foo.tsx
  function foo&lt;T&gt;(arg: T): T {
    return arg
  }
  
  type FooT = typeof foo  // works, but alias isn't generic: &lt;T&gt;(arg: T) =&gt; T
  type FooParametersT = Parameters&lt;typeof foo&gt;  // sure: [unknown]
  type FooReturnT = ReturnType&lt;typeof foo&gt;  // no problem: unknown
  
  type GFooT&lt;T,&gt; = typeof foo&lt;T,&gt;  // yikes
  type GFooParametersT&lt;T,&gt; = Parameters&lt;typeof foo&lt;T,&gt;&gt;  // nope
  type GFooReturnT&lt;T,&gt; = ReturnType&lt;typeof foo&lt;T,&gt;&gt;  // fails
  </code></pre>
  <p>What I'm really trying to do is grab the type of a function in someone else's library and then build an interface around it. For example:</p>
  <pre><code>import { useState } from &quot;react&quot;
  
  type UseStateFnT&lt;T,&gt; = typeof useState&lt;T&gt;
  const wrapUseState: (toWrap: UseStateFnT&lt;T,&gt;) =&gt; UseStateFnT&lt;T,&gt; = …
  </code></pre>
  <p>Is this possible without recreating <a href="https://github.com/DefinitelyTyped/DefinitelyTyped/blob/22ed0c7dd49cb781a2ebc67cf2b2c2fd752c63bd/types/react/index.d.ts#L901-L915" rel="noreferrer">the complex typed function signature</a> myself?</p>