Closed
Description
🔎 Search Terms
getTypeListId, circular reference, conditional types
🕗 Version & Regression Information
- This is a crash
- This changed between versions (confirmed using the Playground)
- ~3.6.3: does not crash
- 3.7.5 ~ 3.8.3: throws
Debug Failure. False expression.
- 3.9.7 ~ 5.6.0-dev.20240628: throws
TypeError: Cannot read properties of undefined (reading 'id')
This is the behavior in every version I tried, and I reviewed the FAQ for entries about "Circularity Errors May Occur In The Presence of Circularities"
⏯ Playground Link
💻 Code
function f<_T, _S>() { // The number of type parameters need to be more than 2 to reproduce, strangely
// Both have to be inside f
interface NumArray<T extends number> extends Array<T> {}
type X = NumArray<X extends {} ? number : number>;
}
🙁 Actual behavior
TypeScript throws the following error when type-checking the code above
throw e;
^
TypeError: Cannot read properties of undefined (reading 'id')
at getTypeListId (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:58078:34)
at createTypeReference (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:58114:16)
at createNormalizedTypeReference (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:59115:100)
at instantiateTypeWorker (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:61599:63)
at instantiateTypeWithAlias (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:61584:20)
at instantiateType (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:61562:29)
at resolveObjectTypeMembers (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:55820:77)
at resolveTypeReferenceMembers (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:55843:5)
at resolveStructuredTypeMembers (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:56666:11)
at getSignaturesOfStructuredType (/Users/wasabi/workspace/typescript/crash/node_modules/typescript/lib/tsc.js:57363:24)
🙂 Expected behavior
For TypeScript not to crash and to display some appropriate error message (such as TS4109).
Additional information about the issue
- The
number
parts in the code are probably irrelevant to the issue: we still get the same crash after replacingnumber
tostring
for example.
Thank you.