diff --git a/src/compiler/program.ts b/src/compiler/program.ts index ff2efa4a2cb..70c421f9d2b 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -658,7 +658,7 @@ namespace ts { const start = new Date().getTime(); ensureDirectoriesExist(getDirectoryPath(normalizePath(fileName))); - if (options.watch && sys.createHash && sys.getModifiedTime) { + if (isWatchSet(options) && sys.createHash && sys.getModifiedTime) { writeFileIfUpdated(fileName, data, writeByteOrderMark); } else { diff --git a/src/compiler/tsc.ts b/src/compiler/tsc.ts index b88dea9d96b..377aca78901 100644 --- a/src/compiler/tsc.ts +++ b/src/compiler/tsc.ts @@ -240,11 +240,6 @@ namespace ts { return typeof JSON === "object" && typeof JSON.parse === "function"; } - function isWatchSet(options: CompilerOptions) { - // Firefox has Object.prototype.watch - return options.watch && options.hasOwnProperty("watch"); - } - export function executeCommandLine(args: string[]): void { const commandLine = parseCommandLine(args); let configFileName: string; // Configuration file name (if any) diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index ee029b7249f..9d92fb064e4 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -2642,6 +2642,11 @@ namespace ts { } return carriageReturnLineFeed; } + + export function isWatchSet(options: CompilerOptions) { + // Firefox has Object.prototype.watch + return options.watch && options.hasOwnProperty("watch"); + } } namespace ts {