TypeScript Version: 3.2.0-dev.20181107
Search Terms:
Type constrain inferred
Code
function test1<P extends any[], R>(
t: ((...args: P) => R),
): (...args: P) => R {
return t;
}
function wrap1<T extends (...args: any[]) => any>(resultFn: T): T{
return resultFn;
}
const test11 = wrap1(test1);
function wrap2<T>(resultFn: T): T{
return resultFn;
}
const test12 = wrap2(test1);
Expected behavior:
typeof test11 should be the same as typeof test1 as the wrap1 function takes T and return T.
Actual behavior:
typeof test11 is more generic than typeof test1. Meanwhile, wrap2 works as intended, except it doesn't have type constrain.
Playground Link:
Playground Link
Related Issues:
N/A
TypeScript Version: 3.2.0-dev.20181107
Search Terms:
Type constrain inferred
Code
Expected behavior:
typeof test11should be the same astypeof test1as thewrap1function takesTand returnT.Actual behavior:
typeof test11is more generic thantypeof test1. Meanwhile,wrap2works as intended, except it doesn't have type constrain.Playground Link:
Playground Link
Related Issues:
N/A