Repository navigation
fix(@angular/build): report TypeScript declaration emit diagnostics - #34436
Merged
alan-agius4 merged 1 commit intoOct 21, 2026
Merged
Conversation
alan-agius4
requested review from
clydin and
dgp1130
and removed request for
dgp1130
October 20, 2026 10:37
alan-agius4
marked this pull request as ready for review
October 20, 2026 10:38
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()`.
alan-agius4
force-pushed
the
fix/aot-declaration-diagnostics
branch
from
October 20, 2026 16:31
ed26919 to
bac51f1
Compare
dgp1130
approved these changes
Oct 21, 2026
Collaborator
Author
|
This PR was merged into the repository. The changes were merged into the following branches:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.