Closed
Description
TypeScript Version: 3.9.1-rc, 4.0.0-dev.20200430
Search Terms: Array flat RangeError Maximum call stack size exceeded
Code
class Foo <T> {
arr: T[] = [];
bar (
depth = 1,
) {
return this.arr.flat(depth);
}
}
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
Activity
b-fuze commentedon May 2, 2020
I can also produce it here
And this compiles fine
But this does not
And this is the tsc (4.0.0-dev.20200501) command:
Edit: After corresponding with @0kku he discovered it also happens with
--declaration
millsp commentedon May 2, 2020
Not able to reproduce the error on 3.9.1-rc or 4.0.0-dev.20200430. Compiles.
b-fuze commentedon May 2, 2020
@pirix-gh It doesn't happen in normal mode, it happens in watch mode.
0kku commentedon May 2, 2020
Looks like it doesn't happen if I comment out
"declaration": true
from my tsconfig. Also with-w
flag it happens regardless of that config option. Here's my tsconfig:Array.prototype.flat
typing is incorrect #38901