Description
This seems to be intentional, but it looks like TSServer always uses fixed polling to watch files regardless of editor configured options.
The relevant code was written 4.5 years ago. Does the TypeScript team plan on revisiting that decision? If not, should the watchFile
option have its choices limited to reduce confusion? (I understand that will partly be a VSCode issue if the answer is yes.)
Personally I think it's strange that this is configurable in tsc
but not tsserver
.
Technical Details:
Here's the watchUtilities.ts
call, which passes a WatchOptions
arg:
TypeScript/src/compiler/watchUtilities.ts
Line 440 in 4885dec
TypeScript/src/compiler/types.ts
Lines 5844 to 5853 in 4885dec
Here's the implemention in tsserver
, which actually overrides the default implementation and ignores the options
arg.
TypeScript/src/tsserver/server.ts
Lines 885 to 890 in 4885dec
tsserver.log
also reports a watchFile
option of 3
(WatchFileKind.UseFsEvents
), which is incorrect.
Info 40 [19:45:41.986] FileWatcher:: Added:: WatchInfo: /Volumes/git/TypeScript/src/server/types.ts 500 {"watchFile":3,"watchDirectory":0} Project: WatchType: Closed Script info
TypeScript Version: v4.2.0-dev.20201112
Search Terms:
- tsserver polling
Steps to Reproduce
Add the following to VSCode settings.json
:
{
"typescript.tsserver.watchOptions": {
"watchFile": "useFsEvents",
}
}
Expected behavior:
- TSServer watches files through FSEvents.
- Updates to watched source files happen almost immediately.
Actual behavior:
- TSServer watches files with fixed polling.