diff --git a/src/compiler/sys.ts b/src/compiler/sys.ts index 6fce65c3f36..e3c304afb8f 100644 --- a/src/compiler/sys.ts +++ b/src/compiler/sys.ts @@ -752,16 +752,17 @@ namespace ts { }; function fileChanged(curr: any, prev: any) { + // previous event kind check is to ensure we recongnize the file as previously also missing when it is restored or renamed twice (that is it disappears and reappears) + // In such case, prevTime returned is same as prev time of event when file was deleted as per node documentation + const isPreviouslyDeleted = +prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted; if (+curr.mtime === 0) { - if (eventKind === FileWatcherEventKind.Deleted) { + if (isPreviouslyDeleted) { // Already deleted file, no need to callback again return; } eventKind = FileWatcherEventKind.Deleted; } - // previous event kind check is to ensure we send created event when file is restored or renamed twice (that is it disappears and reappears) - // since in that case the prevTime returned is same as prev time of event when file was deleted as per node documentation - else if (+prev.mtime === 0 || eventKind === FileWatcherEventKind.Deleted) { + else if (isPreviouslyDeleted) { eventKind = FileWatcherEventKind.Created; } // If there is no change in modified time, ignore the event