Fixes issues with reload because of output emit #39030
Merged
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.
This has two changes:
1020ea2 ensure that if there is no change in folder structure, only files are added or removed the directory watcher is invoked with those fileNames and other wise its invoked with directory name being watched since the watches on child are updated at later time, we wouldn't know comprehensive list of changes. This change helps in optimizing in not having to refresh program when we get better paths for file or directories added
a37585e unifies the logic to ignore wild card directory watch call back invoke. It checks if the file is excluded by config or output file next to the input file so that those emits can be ignored.
Note :
2cf6d4f shows testcase where rootFile thats being renamed invokes file watcher first and update happens... after which the actual directory watcher is invoked.. so there is intermittent program update that still includes file to be renamed but that file is deleted from the disk. So the error is that file not found. After wild card directory update (because of async nature of the directory watching update) the correct error is shown (module not found).
I did consider having to update the filenames if fileWatcher was invoked with file created with deleted but given that the update eventually happens i think it would be extra cost to bet the new files names from the disk on such events for the config and hence decided to keep it as is. Note that before this fix the correct error was never shown till you invoke tsc again.
Fixes #37994, #38684