-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Open
Labels
Milestone
Description
🔎 Search Terms
Private constructor in mixin causes "Cannot read properties of undefined (reading 'declarations')"
private constructor mixin undefined declaration
🕗 Version & Regression Information
- This is the behavior in every version I tried - all the way back to v3.3
⏯ Playground Link
💻 Code
declare abstract class j1 {
private constructor(...args: any[]);
}
declare abstract class j2 {
private constructor(...args: any[]);
}
declare const jS: typeof j1 & typeof j2;
declare class j0 extends jS {
}
🙁 Actual behavior
TypeScript crashes on the above code:
> npx tsc test.ts
/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:123141
throw e;
^
TypeError: Cannot read properties of undefined (reading 'declarations')
at getClassLikeDeclarationOfSymbol (/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:17489:23)
at checkBaseTypeAccessibility (/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:85047:38)
at /Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:84800:11
at addLazyDiagnostic (/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:86811:33)
at checkClassLikeDeclaration (/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:84796:9)
at checkClassDeclaration (/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:84763:5)
at checkSourceElementWorker (/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:86501:16)
at checkSourceElement (/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:86320:7)
at forEach (/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:32:22)
at checkSourceFileWorker (/Users/mak13180/site/esri/arcgis-js-api-4/node_modules/typescript/lib/_tsc.js:86726:7)
Node.js v22.19.0
In case of TS Playground, the error is visible in the browser DevTools console
🙂 Expected behavior
No exception, and no type-checker error.
Works if you remove one of the constructors or the private
modifier.
Additional information about the issue
I was researching how to represent my mixins in .d.ts, without exposing mixin constructors