TypeScript Version: 2.9.2
Search Terms: generic infer contextual type
Code
constbaz: (n: number)=>number=(// param `n` is correctly inferred to be `number` :-)n=>n);constidentity=<T>(t: T)=>t;constbar: (n: number)=>number=identity(// param `n` is inferred as `any`, expected `number` :-(x=>x);
Expected behavior: TypeScript should infer the generic T in identity from the contextual type.
Actual behavior: TypeScript infers the generic T in identity as any!
Playground Link:
Related Issues:
TypeScript Version: 2.9.2
Search Terms: generic infer contextual type
Code
Expected behavior: TypeScript should infer the generic
Tinidentityfrom the contextual type.Actual behavior: TypeScript infers the generic
Tinidentityasany!Playground Link:
Related Issues: