Microsoft/TypeScript
View on GitHubRegression: RangeError: Maximum call stack size exceeded in type instantiation with recursive types and intersections
Open
#62966 opened on Jan 8, 2026
BugDomain: check: Type CircularityHelp Wanted
Description
🔎 Search Terms
Maximum call stack size exceeded
instantiateTypeWithAlias
Infinite recursion crash
Regression 5.9
🕗 Version & Regression Information
5.7.3: Works (Emits TS2589)
5.8.3: Works (Emits TS2589)
5.9.3: Crashes
Nightly: Crashes
⏯ 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) & boolean;
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>>>;}[U extends T ? 0 : 1];
🙁 Actual behavior
.\ts-versions\nightly\node_modules\.bin\tsc.cmd C:\Users\aw\Desktop\itr-new\result0\mutated\infiniteConstraints_mutated_iter9.ts
D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:123181
throw e;
^
RangeError: Maximum call stack size exceeded
at instantiateType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63527:27)
at instantiateList (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63154:24)
at instantiateTypes (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63168:12)
at instantiateTypeWorker (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63592:24)
at instantiateTypeWithAlias (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63560:20)
at instantiateType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63528:29)
at getMappedType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63208:67)
at D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63513:66
at map (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:196:19)
at getConditionalTypeInstantiation (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:63513:29)
Node.js v22.19.0
If I change the intersection type in ExactExtract from & string to & boolean, the compiler's behavior changes from a crash to a hang.
🙂 Expected behavior
The compiler should not crash.
Additional information about the issue
No response