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:
|
watchFile: (file, callback, pollingInterval, options) => host.watchFile(file, callback, pollingInterval, options), |
|
export interface WatchOptions { |
|
watchFile?: WatchFileKind; |
|
watchDirectory?: WatchDirectoryKind; |
|
fallbackPolling?: PollingWatchKind; |
|
synchronousWatchDirectory?: boolean; |
|
excludeDirectories?: string[]; |
|
excludeFiles?: string[]; |
|
|
|
[option: string]: CompilerOptionsValue | undefined; |
|
} |
Here's the implemention in tsserver, which actually overrides the default implementation and ignores the options arg.
|
sys.watchFile = (fileName, callback) => { |
|
const watchedFile = pollingWatchedFileSet.addFile(fileName, callback); |
|
return { |
|
close: () => pollingWatchedFileSet.removeFile(watchedFile) |
|
}; |
|
}; |
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:
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.
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
watchFileoption 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
tscbut nottsserver.Technical Details:
Here's the
watchUtilities.tscall, which passes aWatchOptionsarg: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 theoptionsarg.TypeScript/src/tsserver/server.ts
Lines 885 to 890 in 4885dec
tsserver.logalso reports awatchFileoption of3(WatchFileKind.UseFsEvents), which is incorrect.TypeScript Version: v4.2.0-dev.20201112
Search Terms:
Steps to Reproduce
Add the following to VSCode
settings.json:{ "typescript.tsserver.watchOptions": { "watchFile": "useFsEvents", } }Expected behavior:
Actual behavior: