Repository navigation
Crash: TypeError: Cannot read properties of undefined (reading 'flags') in isFreshLiteralType during recursive tuple expansion with unresolved identifiers #62974
Copy link
Copy link
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: CrashesUnhandled exceptions/panics with no immediate primary root cause identifiedUnhandled exceptions/panics with no immediate primary root cause identifiedHelp WantedYou can do thisYou can do this
Milestone
Description
🔎 Search Terms
isFreshLiteralType
Cannot read properties of undefined (reading 'flags')
getNormalizedType
"Internal Compiler Error"
"Large tuple crash"
🕗 Version & Regression Information
v5.7.3: Crashes
v5.8.3: Crashes
v5.9.3: Crashes
Nightly (6.0.0-dev.20260108): Crashes
⏯ Playground Link
💻 Code
// Repro from #54491
type UnshiftTuple<T extends [...any[]]> = T extends [T[0],...infer Tail] ? Tail : never;
type ExpandSmallerTuples<T extends [...any[]]> = T extends [T[0],...infer Tail] ? T | ExpandSmallerTuples<Tail> : [];
type Shift<A extends Array<any>> = ((...args: A) => void) extends (...args: [A[0], ...infer R]) => void ? R : never;
type GrowExpRev<A extends Array<any>, N extends number, P extends Array<Array<any>>> = A['length'] extends N ? A : GrowExpRev<[...A,...P[0]][N] extends undefined ? [...A,...P[0]] : A, N, Shift<P>>;
// type GrowExp<A extends Array<any>, N extends number, P extends Array<Array<any>>> = [...A, ...A][N] extends undefined ? GrowExp<[...A, ...A], N, [A, ...P]> : GrowExpRev<A, N, P>;
type GrowExp<A extends Array<any>, N extends number, P extends Array<Array<any>>> = [...A,...A][N] extends undefined ? GrowExp<[...A,crash], N, [A, ...P]> : GrowExpRev<A, N, P>;
type Tuple<T, N extends number> = number extends N ? Array<T> : N extends 0 ? [] : N extends 1 ? [T] : GrowExp<[T], N, [[]]>;
declare class ArrayValidator<T extends unknown[], I = T[number]> {
lengthRange<S extends number, E extends number>(start: S, endBefore: E): ArrayValidator<Exclude<ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, E>]>>, ExpandSmallerTuples<UnshiftTuple<[...Tuple<I, S>]>>>>;
}🙁 Actual behavior
.\ts-versions\nightly\node_modules\.bin\tsc.cmd .\mutated\largeTupleTypes_mutated_batch0.ts
D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:123166
throw e;
^
TypeError: Cannot read properties of undefined (reading 'flags')
at isFreshLiteralType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:62933:20)
at getNormalizedType (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:64661:17)
at isRelatedTo (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:65015:21)
at propertiesRelatedTo (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:66695:29)
at structuredTypeRelatedToWorker (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:66300:21)
at structuredTypeRelatedTo (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:65726:21)
at recursiveTypeRelatedTo (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:65677:19)
at isRelatedTo (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:65090:122)
at typeArgumentsRelatedTo (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:65508:25)
at relateVariances (D:\do\typeFuzz\ts-versions\nightly\node_modules\typescript\lib\_tsc.js:66341:23)
Node.js v22.19.0
🙂 Expected behavior
The compiler should not crash.
Additional information about the issue
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: CrashesUnhandled exceptions/panics with no immediate primary root cause identifiedUnhandled exceptions/panics with no immediate primary root cause identifiedHelp WantedYou can do thisYou can do this
Activity
Andarist commentedon Jan 12, 2026
Repros with (and this doesn't depend anyhow on unresolved identifiers/error types/etc):
RyanCavanaugh commentedon Jan 12, 2026
Repros in TS7 as well
ahejlsberg commentedon Jul 24, 2026
Fixed by microsoft/typescript-go#4735.