* @pollingInterval - this parameter is used in polling-based watchers and * ignored in watchers that use native OS file watching
(
path: string,
callback: ts.FileWatcherCallback,
pollingInterval?: number,
options?: ts.WatchOptions,
)
| 64 | * ignored in watchers that use native OS file watching |
| 65 | */ |
| 66 | watchFile( |
| 67 | path: string, |
| 68 | callback: ts.FileWatcherCallback, |
| 69 | pollingInterval?: number, |
| 70 | options?: ts.WatchOptions, |
| 71 | ): ts.FileWatcher { |
| 72 | if (!this.useClientSideFileWatcher) { |
| 73 | return ts.sys.watchFile!(path, callback, pollingInterval, options); |
| 74 | } |
| 75 | |
| 76 | const callbacks = this.fileWatchers.get(path) ?? new Set(); |
| 77 | callbacks.add(callback); |
| 78 | this.fileWatchers.set(path, callbacks); |
| 79 | return { |
| 80 | close: () => { |
| 81 | const callbacks = this.fileWatchers.get(path); |
| 82 | if (callbacks) { |
| 83 | callbacks.delete(callback); |
| 84 | if (callbacks.size === 0) { |
| 85 | this.fileWatchers.delete(path); |
| 86 | } |
| 87 | } |
| 88 | }, |
| 89 | }; |
| 90 | } |
| 91 | |
| 92 | watchDirectory( |
| 93 | path: string, |