TypeScript Version: 2.6.1
Code
type Foo<T> = {
[K in keyof T]: Foo<T[K]>;
};
interface Bar<T> {
bar: Foo<T> | Bar<T>;
}
function a<T>(fooBar: Foo<T> | Bar<T>) {
return b(fooBar); //Doesn't work
// return b<T>(fooBar); //Works
}
function b<T>(fooBar: Foo<T> | Bar<T>) {
}
tsconfig.json
{
"compilerOptions":
{
"target": "ES2015",
"strict": true
}
}
Expected behavior:
Should compile successfully.
Actual behavior:
Compiler crashes with the following output:
tsc.js:58005
throw e;
^
RangeError: Maximum call stack size exceeded
at instantiateType (C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:25752:33)
at instantiateType (C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:25779:49)
at C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:25603:42
at Object.map (C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:469:29)
at getAnonymousTypeInstantiation (C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:25688:40)
at instantiateType (C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:25763:32)
at getTemplateTypeFromMappedType (C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:23662:21)
at inferTypeForHomomorphicMappedType (C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:27543:32)
at inferFromObjectTypes (C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:27757:48)
at inferFromTypes (C:\Users\blind\projects\pss\acorn\node_modules\typescript\lib\tsc.js:27717:29)
The issue seems to be a problem with inferring the generic parameter when calling b() inside of a(). Explicitly supplying the parameter fixes the issue.
TypeScript Version: 2.6.1
Code
tsconfig.json
{ "compilerOptions": { "target": "ES2015", "strict": true } }Expected behavior:
Should compile successfully.
Actual behavior:
Compiler crashes with the following output:
The issue seems to be a problem with inferring the generic parameter when calling b() inside of a(). Explicitly supplying the parameter fixes the issue.