🔎 Search Terms
RangeError: Maximum call stack size exceeded
Recursion limit
Variadic tuple types
Recursive conditional types
isRelatedTo / checkTypeRelatedTo crash
🕗 Version & Regression Information
Versions tested: 5.7.3, 5.8.3, 5.9.3, Nightly, TS7.
⏯ Playground Link
https://www.typescriptlang.org/zh/play/?target=2&ts=6.0.0-dev.20260319&ssl=9&ssc=44&pln=8&pc=1#code/PTAEAEBcEMCcHMCmkBcpEGcBMAGAjAKwBQIEGksAlgMaqgUCuiJYASogA6wD2oAZjwC2oAMQBmABx4AnBKKQAnh0Sh21BrAA8AFQB8oALygAFEVDnQ29AA9IiAHYATDOeMN7Aa3vcA7vYDaALoAlKAA-KAA3gC+oGiRoP4A0qCU9qAeiArcfJaBYWhqGjrJgbrRRKEAPokAdPVFWnr+9gyCAEaIsIFBgQDcRIN87rSU3OkAVtxpOrrGADaFiOpNukHBSyuzUWYWsMga6f4A5IJwmbDHADSg9bXz-UQVw-aj46DQswubxc0haAA3aaOHYWUDUcbkUDWH6rUA1dyORB8NKIEFGKZpBbBAYVIA
💻 Code
// @target: es2015
// @strict: true
// Repro from #38198
type Recur<T> = (
T extends (unknown[]) ? {} : { [K in keyof T]?: Recur<T[K]>}
) | [...Recur<T>[number][]];
function join<T>(l: Recur<T>[]): Recur<T> {
return ['marker', ...l];
}
function a<T>(l: Recur<T>[]): void {
const x: Recur<T> | undefined = join(l);
}
🙁 Actual behavior
node built/local/tsc.js -noEmit recursiveReverseMappedType_filled_0_unvalidated_mutated_batch0.ts
D:\github\TypeScript\built\local\_tsc.js:123721
throw e;
^
RangeError: Maximum call stack size exceeded
at isRelatedTo (D:\github\TypeScript\built\local\_tsc.js:65175:25)
at checkTypeRelatedTo (D:\github\TypeScript\built\local\_tsc.js:64889:20)
at isTypeRelatedTo (D:\github\TypeScript\built\local\_tsc.js:64822:14)
at isTypeIdenticalTo (D:\github\TypeScript\built\local\_tsc.js:63930:12)
at isTypeOrBaseIdenticalTo (D:\github\TypeScript\built\local\_tsc.js:69275:42)
at inferFromMatchingTypes (D:\github\TypeScript\built\local\_tsc.js:68894:15)
at inferFromTypes (D:\github\TypeScript\built\local\_tsc.js:68704:44)
at inferFromTypes (D:\github\TypeScript\built\local\_tsc.js:68776:11)
at inferToMultipleTypes (D:\github\TypeScript\built\local\_tsc.js:68964:15)
at inferFromTypes (D:\github\TypeScript\built\local\_tsc.js:68820:9)
Node.js v22.19.0
🙂 Expected behavior
The compiler should not crash.
Additional information about the issue
No response
🔎 Search Terms
RangeError: Maximum call stack size exceeded
Recursion limit
Variadic tuple types
Recursive conditional types
isRelatedTo / checkTypeRelatedTo crash
🕗 Version & Regression Information
Versions tested: 5.7.3, 5.8.3, 5.9.3, Nightly, TS7.
⏯ Playground Link
https://www.typescriptlang.org/zh/play/?target=2&ts=6.0.0-dev.20260319&ssl=9&ssc=44&pln=8&pc=1#code/PTAEAEBcEMCcHMCmkBcpEGcBMAGAjAKwBQIEGksAlgMaqgUCuiJYASogA6wD2oAZjwC2oAMQBmABx4AnBKKQAnh0Sh21BrAA8AFQB8oALygAFEVDnQ29AA9IiAHYATDOeMN7Aa3vcA7vYDaALoAlKAA-KAA3gC+oGiRoP4A0qCU9qAeiArcfJaBYWhqGjrJgbrRRKEAPokAdPVFWnr+9gyCAEaIsIFBgQDcRIN87rSU3OkAVtxpOrrGADaFiOpNukHBSyuzUWYWsMga6f4A5IJwmbDHADSg9bXz-UQVw-aj46DQswubxc0haAA3aaOHYWUDUcbkUDWH6rUA1dyORB8NKIEFGKZpBbBAYVIA
💻 Code
🙁 Actual behavior
🙂 Expected behavior
The compiler should not crash.
Additional information about the issue
No response