Watch for the creation of missing files#16527
Conversation
When we discover that a file is missing, call sys.watchFile on its path so that we can update our state when it is created. 1) For tsc --watch, we schedule a new build 2) For tsserver, we update the containing projects Caveat: VS will not know about the state change in tsserver until the next time it synchronizes its project list
|
@amcasey, |
|
TODO: I'm still adding tests and cleaning things up, but I'd appreciate feedback on the general approach |
...in favor of calling `fileExists` on each element of `oldProgram.getMissingFilePaths()`.
|
As far as I know, I've addressed all of @mhegazy's offline feedback. I'll focus on testing until I hear otherwise. |
|
Added structure reuse tests and fixed bug where reused program structure dropped missing file list. |
| filesByName.set(filePaths[i], newSourceFiles[i]); | ||
| } | ||
|
|
||
| for (const p of oldProgram.getMissingFilePaths()) { |
There was a problem hiding this comment.
this needs to be under the check of
if (oldProgram.getMissingFilePaths) {There was a problem hiding this comment.
Under what circumstances will getMissingFilePaths ever be undefined?
There was a problem hiding this comment.
I made the property optional in case there were existing implementers of the interface. Was that over-cautious?
| filesByName.set(filePaths[i], newSourceFiles[i]); | ||
| } | ||
|
|
||
| for (const p of oldProgram.getMissingFilePaths()) { |
There was a problem hiding this comment.
Under what circumstances will getMissingFilePaths ever be undefined?
| return; | ||
| } | ||
|
|
||
| // removed = deleted ? true : (added ? false : undefined) |
There was a problem hiding this comment.
Can this comment be removed?
There was a problem hiding this comment.
It was intended as an explanation. If you don't believe it's helpful, I'm happy to remove it.
|
I've posted a cleaned up PR: #16684. |
When we discover that a file is missing, call sys.watchFile on its path so that we can update our state when it is created.
Caveat: VS will not know about the state change in tsserver until the next time it synchronizes its project list