Repository navigation
fix(compiler): invalidate diagnostics for changed module augmentations - #65755
Open
Mohamed Rafik (Mllkmoha) wants to merge 3 commits into
Open
Mohamed Rafik (Mllkmoha) wants to merge 3 commits into
Mohamed Rafik (Mllkmoha) wants to merge 3 commits into
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Augmentation invalidation can silently drop declaration errors without rechecking and retain stale diagnostics after re-export or resolution changes.
3 open issues
What changed in this PR
Addresses #65717 by invalidating cached compiler diagnostics when module augmentations change or disappear.
Changes:
- Persists augmentation fingerprints in build info.
- Invalidates diagnostics for referenced targets when fingerprints change.
- Adds regression tests and updates build-info baselines.
| File | Description |
|---|---|
tsc/testdata/baselines/reference/tsc/compilerOptionChanges/moduleDetection-ambient-module-incremental-direction-1.js |
Updates incremental module-detection baseline. |
tsc/testdata/baselines/reference/tsc/compilerOptionChanges/moduleDetection-ambient-module-incremental-direction-0.js |
Updates reverse-transition baseline. |
tsc/testdata/baselines/reference/tsbuild/lateBoundSymbol/interface-is-merged-and-contains-late-bound-member.js |
Records merged-interface fingerprints. |
tsc/testdata/baselines/reference/tsbuild/dependencyUpdate/rebuilds-transitive-dependents-when-dependency-update-batch-includes-a-global-scope-change.js |
Updates global-change dependency baseline. |
tsc/testdata/baselines/reference/tsbuild/dependencyUpdate/rebuilds-transitive-dependents-when-dependency-update-batch-has-no-global-scope-change.js |
Updates dependency-only baseline. |
tsc/testdata/baselines/reference/tsbuild/dependencyUpdate/rebuilds-files-using-globals-when-global-scope-dependency-is-updated.js |
Records global-augmentation fingerprints. |
tsc/testdata/baselines/reference/tsbuild/compilerOptionChanges/moduleDetection-ambient-module-build-direction-1.js |
Updates build-mode module-detection baseline. |
tsc/testdata/baselines/reference/tsbuild/compilerOptionChanges/moduleDetection-ambient-module-build-direction-0.js |
Updates reverse build-transition baseline. |
tsc/internal/execute/incremental/snapshot.go |
Defines and computes augmentation fingerprints. |
tsc/internal/execute/incremental/programtosnapshot.go |
Compares fingerprints and invalidates target diagnostics. |
tsc/internal/execute/incremental/buildInfo.go |
Serializes and restores fingerprints. |
tsc/internal/execute/incremental/buildinfo_path_test.go |
Tests serialization and legacy field absence. |
tsc/internal/execute/incremental/affectedfileshandler_internal_test.go |
Tests augmentation changes, removal, and Unicode offsets. |
Review effort: Balanced
| if references, ok := refs.getReferences(owner); ok { | ||
| for path := range references.Keys() { | ||
| t.snapshot.semanticDiagnosticsPerFile.Delete(path) | ||
| t.snapshot.emitDiagnosticsPerFile.Delete(path) |
Comment on lines
+184
to
+186
| if references, ok := refs.getReferences(owner); ok { | ||
| for path := range references.Keys() { | ||
| t.snapshot.semanticDiagnosticsPerFile.Delete(path) |
Comment on lines
+192
to
+212
| // Invalidate targets from removed or changed augmentations. | ||
| t.oldProgram.snapshot.fileInfos.Range(func(path tspath.PathKey, oldInfo *FileInfo) bool { | ||
| newInfo, exists := t.snapshot.fileInfos.Load(path) | ||
| if oldInfo.moduleAugmentations != "" && | ||
| (!exists || | ||
| oldInfo.moduleAugmentations != newInfo.moduleAugmentations) { | ||
| invalidateReferences(&t.oldProgram.snapshot.referencedMap, path) | ||
| } | ||
| return true | ||
| }) | ||
|
|
||
| // Invalidate targets from added or changed augmentations. | ||
| t.snapshot.fileInfos.Range(func(path tspath.PathKey, newInfo *FileInfo) bool { | ||
| oldInfo, exists := t.oldProgram.snapshot.fileInfos.Load(path) | ||
| if newInfo.moduleAugmentations != "" && | ||
| (!exists || | ||
| newInfo.moduleAugmentations != oldInfo.moduleAugmentations) { | ||
| invalidateReferences(&t.snapshot.referencedMap, path) | ||
| } | ||
| return true | ||
| }) |
This branch has not been deployed
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.


Summary
Testing
go test ./tsc/internal/execute/incremental -count=1go test ./tsc/internal/execute/... -count=1go test ./tsc/... -count=1git diff --checkFixes #65717
AI assistance
AI tools assisted with implementation and testing. I reviewed the changes and test results.