Repository navigation
fix(@angular/build): report TypeScript declaration emit diagnostics - #34436
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces tracking and reporting of TypeScript declaration emit diagnostics in the Angular AOT compilation process, ensuring they are preserved and correctly recovered from in watch mode. It adds comprehensive tests for these scenarios. A review comment points out a potential compilation error under strictNullChecks where affectedEmitResult needs to allow undefined values.
When TypeScript encounters a declaration emit error (such as `TS2742`, `TS4023`, `TS4060`, or `TS9005`), it skips emitting the `.d.ts` file and returns the diagnostic in `emitResult.diagnostics`. Previously, `AotCompilation.emitAffectedFiles()` discarded `emitResult.diagnostics` and `collectDiagnostics()` did not yield declaration emit diagnostics, causing library builds to fail later with a secondary `UNRESOLVED_IMPORT` error in `rolldown-plugin-dts`. Store declaration emit diagnostics returned by `emitNextAffectedFile()` and `typeScriptProgram.emit()` per `SourceFile` in `AngularCompilationState` (preserving them across incremental rebuilds for files that are not re-emitted) and yield them during `collectDiagnostics()`.
ed26919 to
bac51f1
Compare
|
This PR was merged into the repository. The changes were merged into the following branches:
|
|
This pull request has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
emitResult.diagnosticsreturned bytypeScriptProgram.emitNextAffectedFile(...)andtypeScriptProgram.emit(...)duringemitAffectedFiles()inAotCompilationwithout running TypeScript's declaration emitter a second time.SourceFiledeclaration emit diagnostics (TS2742,TS4023,TS4060,TS9005, etc.) inAngularCompilationState.declarationDiagnostics(WeakMap<ts.SourceFile, readonly ts.Diagnostic[]>) and yield them incollectDiagnostics()whenDiagnosticModes.Semanticis enabled.build_spec.tsandwatch_spec.tsverifying declaration emit error reporting and watch-mode recovery.