Skip to content

Commit

Permalink
fix: pass watch options to watchFile and watchDirectory
Browse files Browse the repository at this point in the history
The options are needed so that the server respects the `WatchOptions`
provided by users in their tsconfig.json.

```ts
    export interface WatchOptions {
        watchFile?: WatchFileKind;
        watchDirectory?: WatchDirectoryKind;
        fallbackPolling?: PollingWatchKind;
        synchronousWatchDirectory?: boolean;
        excludeDirectories?: string[];
        excludeFiles?: string[];
        [option: string]: CompilerOptionsValue | undefined;
    }
```

fix #636
  • Loading branch information
kyliau committed Apr 19, 2021
1 parent 743f9a9 commit 698d7af
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions server/src/server_host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,19 @@ export class ServerHost implements ts.server.ServerHost {
* @pollingInterval - this parameter is used in polling-based watchers and
* ignored in watchers that use native OS file watching
*/
watchFile(path: string, callback: ts.FileWatcherCallback, pollingInterval?: number):
ts.FileWatcher {
return ts.sys.watchFile!(path, callback, pollingInterval);
watchFile(
path: string, callback: ts.FileWatcherCallback, pollingInterval?: number,
options?: ts.WatchOptions): ts.FileWatcher {
return ts.sys.watchFile!(path, callback, pollingInterval, options);
}

watchDirectory(path: string, callback: ts.DirectoryWatcherCallback, recursive?: boolean):
ts.FileWatcher {
watchDirectory(
path: string, callback: ts.DirectoryWatcherCallback, recursive?: boolean,
options?: ts.WatchOptions): ts.FileWatcher {
if (this.isG3 && path.startsWith('/google/src')) {
return NOOP_WATCHER;
}
return ts.sys.watchDirectory!(path, callback, recursive);
return ts.sys.watchDirectory!(path, callback, recursive, options);
}

resolvePath(path: string): string {
Expand Down

0 comments on commit 698d7af

Please sign in to comment.