Skip to content

RangeError when trying to infer type for Array.prototype.flat() #38298

Closed
@0kku

Description

@0kku

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

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions