-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RangeError when trying to infer type for Array.prototype.flat() #38298
Comments
I can also produce it here function foo<T>(arr: T[], depth: number) {
return arr.flat(depth);
} And this compiles fine function foo<T>(arr: T[]) {
return arr.flat(5);
} But this does not function foo<T>(arr: T[]) {
return arr.flat(<number> 5);
} And this is the tsc (4.0.0-dev.20200501) command: tsc flat-test.ts --lib es2019 -m ESNext -t ESNEXT -w Edit: After corresponding with @0kku he discovered it also happens with tsc flat-test.ts --lib es2019 -m ESNext -t ESNEXT --declaration |
Not able to reproduce the error on 3.9.1-rc or 4.0.0-dev.20200430. Compiles. |
@pirix-gh It doesn't happen in normal mode, it happens in watch mode. |
Looks like it doesn't happen if I comment out {
"compilerOptions": {
"lib": ["es2019"],
"declaration": true,
"outDir": "./dist",
"rootDir": "./src",
}
} |
TypeScript Version: 3.9.1-rc, 4.0.0-dev.20200430
Search Terms: Array flat RangeError Maximum call stack size exceeded
Code
Expected behavior:
Code compiles without errors.
Actual behavior:
TSC crashes with
RangeError: Maximum call stack size exceeded
. Edit: Only happens when either--watch
or--declaration
flag is set.Playground Link: Couldn't figure out how to add newer libs for Array, and not super useful anyway, as the compiler crashes
Related Issues:
#32131 seems to be the breaking PR
#36554 seems related maybe
edit: simplified code example
The text was updated successfully, but these errors were encountered: