title: Typescript Function with Generic Return Type
body: <pre><code>type FuncGenericReturn = &lt;T&gt;() =&gt; T;
  const funcReturnsNumber: FuncGenericReturn = (): number =&gt; 1;
  </code></pre>
  
  <p>(<a href="http://www.typescriptlang.org/play/?ssl=1&amp;ssc=1&amp;pln=2&amp;pc=62#code/C4TwDgpgBAYgrgOwMYHEIIgJwJZIEoTByYJQC8UAPACoB8AFAJTm1TUDcAUEgPYIDOwKADNE+QsQEA5OAFsARlgBcsMWgw5xREuShMVCOYswsoARnZA" rel="noreferrer">Sandbox</a>)</p>
  
  <p>Getting this error:</p>
  
  <blockquote>
    <p>Type 'number' is not assignable to type 'T'.
      'number' is assignable to the constraint of type 'T', but 'T' could be instantiated with a different subtype of constraint '{}'.(2322)
    input.ts(1, 26): The expected type comes from the return type of this signature.</p>
  </blockquote>
  
  <p>I would expect typescript to automatically infer T as number and just use it. Why is it complaining? What is the proper way to write something like this? Thanks.</p>