Microsoft/TypeScript

Private constructor in mixin causes "Cannot read properties of undefined (reading 'declarations')"

Open

#62614 opened on Oct 16, 2025

View on GitHub
 (0 comments) (0 reactions) (0 assignees)TypeScript (48,455 stars) (6,726 forks)batch import
BugDomain: classesHelp Wanted

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

https://www.typescriptlang.org/play/?#code/PTAEHkAUFEDlQEICVwHUDK0mgMLluuADLSgC0omp0AGjtJACoCS+AUGwCYCmAxgDYBDAE7dQggEYBnAC7DBvGaAGCpU0ACsAjKADebUKAAOwgJYA3QTLG8A9gDtZwgK6LbwgBQA6HyIDmUgBc4vYAngDaALoAlADcbAC+XHxCouLScgpKKmqaAEx6BsZmltbKDk6uMu7evsIBwYJhUXGJySppdo5KGujBMqFG3LYAZpo6AGSgA0Oj+fE8HTZCuRoADKDcAB7W9pzqvYVJbCCgsLabwsLuoBJ8gs5SYoyD3Oi8ZkbZ8lIAFtycNhdWTiYL2ZwAWzuwlAAF5QAAiJymex+BGxIA

💻 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

Contributor guide