-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Open
@sachithanandhampalaniswamy
Please provide the environment you discovered this bug in (run
Description
Which @angular/* package(s) are the source of the bug?
compiler-cli
Is this a regression?
No
Description
When building an Angular 21 application with TypeScript 5.9.2, the build fails with a TypeScript compiler error during the getOptionsDiagnostics phase. The error occurs in TypeScript's internal code when processing file references.
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
X [ERROR] Cannot destructure property 'pos' of 'file.referencedFiles[index]' as it is undefined. [plugin angular-compiler]
node_modules/typescript/lib/typescript.js:126740:9:
126740 │ ({ pos, end } = file.referencedFiles[index]);
╵ ^
at getReferencedFileLocation (node_modules/typescript/lib/typescript.js:126740:10)
at fileIncludeReasonToDiagnostics (node_modules/typescript/lib/typescript.js:133580:31)
at processReason (node_modules/typescript/lib/typescript.js:130143:62)
at Array.forEach (<anonymous>)
at createDiagnosticExplainingFile (node_modules/typescript/lib/typescript.js:130095:42)
at node_modules/typescript/lib/typescript.js:130028:15
at Array.forEach (<anonymous>)
at Object.getCombinedDiagnostics (node_modules/typescript/lib/typescript.js:130024:78)
at getProgramDiagnostics (node_modules/typescript/lib/typescript.js:127993:57)
at getSemanticDiagnosticsForFile (node_modules/typescript/lib/typescript.js:128024:7)
This error came from the "onStart" callback registered here:
node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:120:18:
120 │ build.onStart(async () => {
╵ ~~~~~~~
at setup (node_modules/@angular/build/src/tools/esbuild/angular/compiler-plugin.js:120:19)
at async handlePlugins (node_modules/esbuild/lib/main.js:1185:20)
Please provide the environment you discovered this bug in (run ng version)
Angular CLI: 21.0.5
Angular: 21.0.5
TypeScript: 5.9.2
npm: 10.9.3
OS: Windows 10
Anything else?
Configuration Files
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"strict": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"skipLibCheck": true,
"skipDefaultLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"isolatedModules": true,
"experimentalDecorators": true,
"importHelpers": true,
"target": "ES2022",
"module": "preserve",
"useDefineForClassFields": false,
"lib": ["ES2022", "dom"],
"moduleResolution": "bundler",
"baseUrl": "./src",
"paths": {
"@app/*": ["app/*"],
"@common/*": ["app/common/*"],
"@services/*": ["app/services/*"],
"@components/*": ["app/components/*"],
"@shared/*": ["app/shared/*"],
"@environments/*": ["environments/*"]
}
},
"angularCompilerOptions": {
"enableI18nLegacyMessageIdFormat": false,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
},
"files": [],
"references": [
{
"path": "./tsconfig.app.json"
},
{
"path": "./tsconfig.spec.json"
}
]
}Attempted Workarounds
- ✅ Removed project references from
tsconfig.json- Error persists - ✅ Added
skipDefaultLibCheck: true- Error persists - ✅ Tried
disableReferencedProjectLoad: true- Error persists - ✅ Excluded backup files from compilation - Error persists
- ✅ Tested both TypeScript 5.9.2 and 5.9.3 - Error persists in both
- ✅ Cleared npm cache and performed clean install - Error persists
- ✅ Cleared Angular build cache - Error persists
Additional Notes
- The error occurs during the TypeScript compiler's
getOptionsDiagnosticsphase - The error happens in TypeScript's internal code, not in the project's source code
- The build process completes the bundling phase but fails during type checking
- This appears to be a bug in TypeScript 5.9.x when used with Angular 21's build system
- The error is consistent and reproducible on every build attempt