Repository navigation
fix(@angular/build): preserve incremental .d.ts signatures and emit state in watch mode - #34343
Open
alan-agius4 wants to merge 2 commits into
Open
alan-agius4 wants to merge 2 commits into
alan-agius4 wants to merge 2 commits into
Conversation
…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.
There was a problem hiding this comment.
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.
… emit state in watch mode
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.
.ngtypecheck.tsshims aftercollectDiagnostics()usingemitNextAffectedFilewithisolatedModulesandassumeChangesOnlyAffectDirectDependenciesenabled so TypeScript does not walkreferencedMapfrom.ngtypecheck.tsshims to component.tsfiles and their transitive importers, preserving their.d.tsshape signatures and keepingaffectedFilesPendingEmitclean for the next watch rebuild.beforetransformers (ivyTransformFactory) have executed on the originalSourceFileprior toafterDeclarations(declarationTransformFactory) when TypeScript performs a.d.ts-only emit (emitOnly = Dts) for transitive importers.SourceFileas having completed JS emit inwriteFileCallbackwhen only a.d.tsor.mapfile was emitted during a.d.ts-only check, and passts.EmitOnly.Jsin the fallback loop when.d.tswas already emitted.BuilderProgramshape signatures are reset tosourceFile.versionbyhandleDtsMayChangeOfduringfindAffectedFiles()sopopulatePreviousDtsSignatures()restores their.d.tssignatures if they are modified on a subsequent rebuild.