Skip to content

fix(@angular/build): report TypeScript declaration emit diagnostics - #34436

Merged
alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix/aot-declaration-diagnostics
Oct 21, 2026
Merged

alan-agius4 merged 1 commit into
angular:mainfrom
alan-agius4:fix/aot-declaration-diagnostics

Conversation

@alan-agius4

@alan-agius4 alan-agius4 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator
  • Capture emitResult.diagnostics returned by typeScriptProgram.emitNextAffectedFile(...) and typeScriptProgram.emit(...) during emitAffectedFiles() in AotCompilation without running TypeScript's declaration emitter a second time.
  • Cache per-SourceFile declaration emit diagnostics (TS2742, TS4023, TS4060, TS9005, etc.) in AngularCompilationState.declarationDiagnostics (WeakMap<ts.SourceFile, readonly ts.Diagnostic[]>) and yield them in collectDiagnostics() when DiagnosticModes.Semantic is enabled.
  • Add integration tests in build_spec.ts and watch_spec.ts verifying declaration emit error reporting and watch-mode recovery.

@alan-agius4
alan-agius4 requested review from clydin and dgp1130 and removed request for dgp1130 October 20, 2026 10:37
@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label Oct 20, 2026
@alan-agius4 alan-agius4 self-assigned this Oct 20, 2026
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label Oct 20, 2026
@alan-agius4
alan-agius4 marked this pull request as ready for review October 20, 2026 10:38
@alan-agius4
alan-agius4 requested review from dgp1130 and removed request for clydin October 20, 2026 10:38
@alan-agius4 alan-agius4 removed their assignment Oct 20, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread packages/angular/build/src/tools/angular/compilation/aot-compilation.ts Outdated
@alan-agius4 alan-agius4 added target: minor This PR is targeted for the next minor release and removed target: patch This PR is targeted for the next patch release labels Oct 20, 2026
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
alan-agius4 force-pushed the fix/aot-declaration-diagnostics branch from ed26919 to bac51f1 Compare October 20, 2026 16:31
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Oct 21, 2026
@alan-agius4
alan-agius4 merged commit c3881e9 into angular:main Oct 21, 2026
40 checks passed
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

@alan-agius4
alan-agius4 deleted the fix/aot-declaration-diagnostics branch October 21, 2026 06:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/build target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants