TypeScript Version: 3.2.2
Search Terms: Generics, lookahead, type inference
Code
functioncall<P1,R>(f: (p1: P1)=>R,p1: P1): R{returnf(p1);}functionidentity<T>(o: T): T{returno;}constx=call(identity,1);// When the parameters are reversed, it works:functioncallReversed<P1,R>(p1: P1,f: (p1: P1)=>R): R{returnf(p1);}consty=callReversed(1,identity);Expected behavior:
x is of type number
Actual behavior:
x is of type {}
only y is of type number
Playground Link:Playground link
Related Issues: I didn't find anything related, but maybe I have been using the wrong search term ("lookahead").
TypeScript Version: 3.2.2
Search Terms: Generics, lookahead, type inference
Code
Expected behavior:
xis of typenumberActual behavior:
xis of type{}only
yis of type numberPlayground Link:Playground link
Related Issues: I didn't find anything related, but maybe I have been using the wrong search term ("lookahead").