Maximum call stack size exceeded when emitting declaration file that should reference an unnameable infinite conditional type #44225
Labels
Bug
A bug in TypeScript
Fixed
A PR has been merged for this issue
Rescheduled
This issue was previously scheduled to an earlier milestone
Milestone
Bug Report
π Search Terms
maximum call stack size exceeded, declaration emit, unnameable, unnamable, unexported, infinite conditional type
π Version & Regression Information
Crash on
4.2.4
,4.3.0-beta
,4.4.0-dev.20210523
β― Repo Link
https://github.com/bluepichu/typescript-issue-44225
(Can't use the playground since this requires multiple files.)
π» Code
Note: this only occurs with declaration emit enabled (since it's a crash in declaration emit), and only when
TupleIntersection
is not exported (see "workaround" below).π Actual behavior
Crash during declaration emit:
π Expected behavior
Notes and Workaround
If
TupleIntersection
is exported bya.ts
, then you get the compile error as expected and no crash, even ifb.ts
doesn't explicitly import it. This is because, sincea.ts
is exportingTupleIntersection
, it can be referenced inb.d.ts
asimport("./a").TupleIntersection
.I think the issue here is that declaration emit is trying to infinitely unroll the conditional type since it has no name for the type that it can reference. I'm not really sure what the compiler is supposed to do in this case though. (Maybe it should complain at the
intersectionCheck
declaration ina.ts
that it's using a private name that needs to be exported?)I think this is probably the same issue referenced by this comment on #42948, though the top-level issue there seems to have a different (though possibly related) cause.
The text was updated successfully, but these errors were encountered: