Closed
Description
Bug Report
π Search Terms
- watch
π Version & Regression Information
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about configuring watch
β― Playground Link
N/A
π» Code
Steps to reproduce:
- In a Git repository with the following files:
main.ts
andtsconfig.json
:{ "files": ["./main.ts"] }
- Modify
main.ts
so Git has unstaged changes and then run:$ tsc --project tsconfig.json --watch --diagnostics
- Finally, run
git diff
.
π Actual behavior
tsc
rebuilds because git diff
bumps the access timestamp (see stat -x main.ts
).
This is particularly problematic for me because I use lazygit
which refreshes the Git diff every few seconds.
Screen.Recording.2023-02-20.at.20.07.44.2.mov
--
Output from tsc
:
FileWatcher:: Triggered with /Users/oliverash/Development/temp/lazygit-refresh-tsc/main.ts 1:: WatchInfo: /Users/oliverash/Development/temp/lazygit-refresh-tsc/main.ts 250 undefined Source file
Scheduling update
Elapsed:: 0ms FileWatcher:: Triggered with /Users/oliverash/Development/temp/lazygit-refresh-tsc/main.ts 1:: WatchInfo: /Users/oliverash/Development/temp/lazygit-refresh-tsc/main.ts 250 undefined Source file
Synchronizing program
π Expected behavior
tsc
should not rebuild when the access timestamp changes.
I suspect this is due to the behaviour of fs.watch
. In that case, is there anything else we can do to improve the default behaviour for macOS users? (Assuming this issue only occurs on macOS because I haven't been able to test on other platforms.)
Note I am able to workaround by setting any of the following variables in my shell RC file:
export TSC_WATCHFILE=DynamicPriorityPolling
export TSC_WATCHFILE=PriorityPollingInterval
export TSC_WATCHFILE=UseFsEvents
export TSC_WATCHFILE=UseFsEventsOnParentDirectory
export TSC_NONPOLLING_WATCHER=true