You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Prevent emitted files from retriggering native watch builds - #65475
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
Watch mode can miss valid new inputs due to inconsistent extension casing and suppression of files never emitted, while regression tests do not cover same-directory output loops.
The reason will be displayed to describe this comment to others. Learn more.
🟡 Changes recommended
The append-only emittedFiles set retains stale output paths, causing watch mode to miss recreated independent declarations; entries need lifecycle-aware cleanup and regression coverage.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
Directory-replacement updates can retain stale source contents and resolutions, while excluded-directory and restored-output events can still trigger unnecessary watch rebuilds.
No open issues 🎉
3 previously missed issues
In code that hasn't changed since last review
Force full rebuild when tracked dependency directories are replaced
tsc/internal/execute/watcher.go:324
A directory replacement can be coalesced into EventUpdate, so this delete-only guard leaves program reuse enabled. If the root filenames stay unchanged and another source is edited in the same batch, the single-file fast path can retain stale contents and resolutions from the replaced directory. Invalidate cached descendants and force a full rebuild for updates to directories containing tracked dependencies; add a regression covering that mixed event batch.
Filter excluded output-directory events from watch cycles
tsc/internal/execute/watcher.go:418
The macOS repro in #64037 still passes this filter: with include: ["**/*"], exclude: ["build"], and tsBuildInfoFile: "./build/tsconfig.tsbuildinfo", the backend delivers updates for both /repro/build and the build-info file. Although the file event is now removed, the directory event survives solely because it is under the recursive watch, so DoCycle still reports a change and rebuilds after emission. Please filter excluded output-directory events too, while preserving directories containing genuine dependencies or discoverable inputs, and add a regression test delivering this pair of events.
Track outputs restored from build info to avoid spurious rebuilds
tsc/internal/execute/watcher.go:709
Outputs restored from build info are never registered here if incremental emission skips their writes. For example, prebuild a composite project that emits declarations alongside its sources, then start --watch without changing the inputs: the existing .d.ts files remain active outputs, but emittedFiles starts empty and this callback is not invoked for them. An event for one of those declarations therefore passes filterRelevantChanges as a new wildcard input and triggers an unnecessary rebuild. Initialize output tracking from confirmed restored emission state as well as successful writes, and add a prebuild/restart regression case; do not blanket-register potential outputs that were never emitted.
Recursive wildcard roots describe directories, not arbitrary event
paths. Treating every descendant as a directory lets emitted outputs
and unrelated files retrigger compilation indefinitely.
Filter events using dependencies, supported extensions, exclusions,
and confirmed outputs. Keep output records aligned with their active
producers, including outputs restored when incremental watch restarts.
Preserve discovery of new inputs and invalidate cached dependencies
when directories are replaced, including coalesced directory-to-file
changes beneath package boundaries.
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
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.
Caught this in an audit.
Fixes #64037 (which I did not realize before making this fix)