From 638cf5b7b880f770fae8c3942352153a51f64965 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Thu, 4 Oct 2018 15:55:17 -0700 Subject: [PATCH 1/2] Ignore the directory watchers invoked in non polling watch mode with no relative file name information Fixes #27326 --- src/compiler/sys.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 713085f192..5aaa331f58 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -796,11 +796,10 @@ namespace ts { dirName, (_eventName: string, relativeFileName) => { // When files are deleted from disk, the triggered "rename" event would have a relativefileName of "undefined" - const fileName = !isString(relativeFileName) - ? undefined! // TODO: GH#18217 - : getNormalizedAbsolutePath(relativeFileName, dirName); + if (!isString(relativeFileName)) { return; } + const fileName = getNormalizedAbsolutePath(relativeFileName, dirName); // Some applications save a working file via rename operations - const callbacks = fileWatcherCallbacks.get(toCanonicalName(fileName)); + const callbacks = fileName && fileWatcherCallbacks.get(toCanonicalName(fileName)); if (callbacks) { for (const fileCallback of callbacks) { fileCallback(fileName, FileWatcherEventKind.Changed); From 585420e9fae2ee381ed64d7b92cd4b773f0d7ca3 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Tue, 9 Oct 2018 08:42:27 -0700 Subject: [PATCH 2/2] Updated callback signature --- src/compiler/sys.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 5aaa331f58..0f90748f3c 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -846,7 +846,7 @@ namespace ts { } } - type FsWatchCallback = (eventName: "rename" | "change", relativeFileName: string) => void; + type FsWatchCallback = (eventName: "rename" | "change", relativeFileName: string | undefined) => void; function createFileWatcherCallback(callback: FsWatchCallback): FileWatcherCallback { return (_fileName, eventKind) => callback(eventKind === FileWatcherEventKind.Changed ? "change" : "rename", "");