-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Open
Labels
BugA bug in TypeScriptA bug in TypeScript
Milestone
Description
🔎 Search Terms
RangeError: Maximum call stack size exceeded
instantiateTypeWorker recursion
instantiateTypeWithAlias crash
Domain: check: Type Circularity
🕗 Version & Regression Information
5.7.3 / 5.8.3 / 5.9.3 / Nightly: Crashes with RangeError.
TS 7.0 : TIMEOUT
⏯ Playground Link
💻 Code
// Repro from #31823
export type Prepend<Elm, T extends unknown[]> =
T extends unknown ?
((arg: Elm, ...rest: T) => void) extends ((...args: infer T2) => void) ? T2 :
never :
never;
export type ExactExtract<T, U> = (T extends U ? U extends T ? T : never : never) & string;
type Conv<T, U = T> = {
0: [T];
1: Prepend<T, Conv<ExactExtract<U, T>, {a: number}>>;
}[U extends T ? 0 : 1];🙁 Actual behavior
node built/local/tsc.js -noEmit infiniteConstraints_mutated_batch12.ts
D:\github\TypeScript\built\local\_tsc.js:123721
throw e;
^
RangeError: Maximum call stack size exceeded
at instantiateType (D:\github\TypeScript\built\local\_tsc.js:63702:27)
at instantiateList (D:\github\TypeScript\built\local\_tsc.js:63329:24)
at instantiateTypes (D:\github\TypeScript\built\local\_tsc.js:63343:12)
at instantiateTypeWorker (D:\github\TypeScript\built\local\_tsc.js:63768:24)
at instantiateTypeWithAlias (D:\github\TypeScript\built\local\_tsc.js:63736:20)
at instantiateType (D:\github\TypeScript\built\local\_tsc.js:63703:29)
at instantiateList (D:\github\TypeScript\built\local\_tsc.js:63329:24)
at instantiateTypes (D:\github\TypeScript\built\local\_tsc.js:63343:12)
at instantiateTypeWorker (D:\github\TypeScript\built\local\_tsc.js:63787:72)
at instantiateTypeWithAlias (D:\github\TypeScript\built\local\_tsc.js:63736:20)
Node.js v22.19.0
🙂 Expected behavior
The fix implemented in #63136 is being bypassed by this specific construction. While the PR intended to yield an errorType when hitting the depth limit, this case triggers a RangeError before the compiler can recover or emit TS2589.
Additional information about the issue
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScript