Closed
Description
TypeScript Version: any
Code
let identity = (x) => x; // degenerates to `(x: any) => any` instead of <T>(x: T) => T
let wrong: number = identity('foo'); // type-checks, while TS should have enough info to infer it's wrong
Expected behavior:
TS should be able to save parameter types (where unspecified) into generics so as to improve inference.
Actual behavior:
Things type-check while TS should have enough info to conclude they shouldn't.
Perhaps this could make for a compiler flag?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment