Skip to content

fix(@angular/build): preserve incremental .d.ts signatures and emit state in watch mode - #34343

Open
alan-agius4 wants to merge 2 commits into
angular:mainfrom
alan-agius4:aot-incremental-dts-fix
Open

alan-agius4 wants to merge 2 commits into
angular:mainfrom
alan-agius4:aot-incremental-dts-fix

Conversation

@alan-agius4

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

Copy link
Copy Markdown
Collaborator
  • Drain newly created .ngtypecheck.ts shims after collectDiagnostics() using emitNextAffectedFile with isolatedModules and assumeChangesOnlyAffectDirectDependencies enabled so TypeScript does not walk referencedMap from .ngtypecheck.ts shims to component .ts files and their transitive importers, preserving their .d.ts shape signatures and keeping affectedFilesPendingEmit clean for the next watch rebuild.
  • Ensure before transformers (ivyTransformFactory) have executed on the original SourceFile prior to afterDeclarations (declarationTransformFactory) when TypeScript performs a .d.ts-only emit (emitOnly = Dts) for transitive importers.
  • Avoid marking a SourceFile as having completed JS emit in writeFileCallback when only a .d.ts or .map file was emitted during a .d.ts-only check, and pass ts.EmitOnly.Js in the fallback loop when .d.ts was already emitted.
  • Track transitive importers whose BuilderProgram shape signatures are reset to sourceFile.version by handleDtsMayChangeOf during findAffectedFiles() so populatePreviousDtsSignatures() restores their .d.ts signatures if they are modified on a subsequent rebuild.

…tate in watch mode

- Drain newly created .ngtypecheck.ts shims after collectDiagnostics() using emitNextAffectedFile with isolatedModules and assumeChangesOnlyAffectDirectDependencies enabled so TypeScript does not reset .d.ts shape signatures or queue component files into affectedFilesPendingEmit for the next rebuild.
- Ensure before transformers run prior to afterDeclarations during .d.ts-only emits so Angular's declarationTransformFactory always has populated dtsTransforms.
- Only record source files as emitted when JS output is produced (not on .d.ts-only checks), and pass ts.EmitOnly.Js in the fallback loop when .d.ts was already emitted.
- Track transitive importers whose BuilderProgram signatures are reset to sourceFile.version by handleDtsMayChangeOf so populatePreviousDtsSignatures restores their .d.ts signatures on subsequent edits.

@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 improves incremental compilation and rebuild behavior in AOT compilation, particularly when isolatedModules is enabled or when .d.ts signatures are modified. It introduces a helper to ensure pre-declaration transformers are executed before declaration transforms during .d.ts-only emits, and tracks transitive importers to restore their .d.ts signatures. Additionally, two new watch-mode integration tests are added. Feedback suggests using the explicit ts.EmitOnly.Js enum instead of the magic number 0 cast to boolean to improve code readability.

@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: minor This PR is targeted for the next minor release labels Oct 14, 2026
@alan-agius4
alan-agius4 requested a review from dgp1130 October 14, 2026 13:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer 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.

1 participant