-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type Circularitystackoverflows caused by circularities, or unexpected errors where no circularity appears to existstackoverflows caused by circularities, or unexpected errors where no circularity appears to existHelp WantedYou can do thisYou can do this
Milestone
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
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: check: Type Circularitystackoverflows caused by circularities, or unexpected errors where no circularity appears to existstackoverflows caused by circularities, or unexpected errors where no circularity appears to existHelp WantedYou can do thisYou can do this