From 76bf47007201923503aee6b1214be12c28450530 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 29 Jan 2018 15:41:21 -0800 Subject: [PATCH 1/2] Simplify isEmittedFile check instead of iterating through all source files. Fixes #21459 --- src/compiler/program.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 23f9b08aa798c..6ea50b30f6f75 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2363,9 +2363,30 @@ namespace ts { return false; } - return forEachEmittedFile(getEmitHost(), ({ jsFilePath, declarationFilePath }) => - isSameFile(jsFilePath, file) || - (declarationFilePath && isSameFile(declarationFilePath, file))); + // If this is source file, its not emitted file + const filePath = toPath(file); + if (getSourceFileByPath(filePath)) { + return false; + } + + // If options have --outFile or --out just check that + const out = options.outFile || options.out; + if (out) { + return isSameFile(filePath, out) || isSameFile(filePath, removeFileExtension(out) + Extension.Dts); + } + + // If --outDir, check if file is in that directory + if (options.outDir) { + return containsPath(options.outDir, filePath, currentDirectory, !host.useCaseSensitiveFileNames()); + } + + if (fileExtensionIsOneOf(filePath, supportedJavascriptExtensions) || fileExtensionIs(filePath, Extension.Dts)) { + // Otherwise just check if sourceFile with the name exists + const filePathWithoutExtension = removeFileExtension(filePath); + return !!getSourceFileByPath(combinePaths(filePathWithoutExtension, Extension.Ts) as Path) || + !!getSourceFileByPath(combinePaths(filePathWithoutExtension, Extension.Tsx) as Path); + } + return false; } function isSameFile(file1: string, file2: string) { From 659424e33f08e3b9ac5ae41ca941deba5b58f528 Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 29 Jan 2018 16:02:16 -0800 Subject: [PATCH 2/2] Log more info about platform for further diagnosis --- src/server/server.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/server/server.ts b/src/server/server.ts index 8e53c4d51092a..722193829f980 100644 --- a/src/server/server.ts +++ b/src/server/server.ts @@ -33,6 +33,7 @@ namespace ts.server { const os: { homedir?(): string; tmpdir(): string; + platform(): string; } = require("os"); interface NodeSocket { @@ -824,8 +825,9 @@ namespace ts.server { const logger = createLogger(); const sys = ts.sys; + const nodeVersion = getNodeMajorVersion(); // use watchGuard process on Windows when node version is 4 or later - const useWatchGuard = process.platform === "win32" && getNodeMajorVersion() >= 4; + const useWatchGuard = process.platform === "win32" && nodeVersion >= 4; const originalWatchDirectory: ServerHost["watchDirectory"] = sys.watchDirectory.bind(sys); const noopWatcher: FileWatcher = { close: noop }; // This is the function that catches the exceptions when watching directory, and yet lets project service continue to function @@ -980,8 +982,9 @@ namespace ts.server { }; logger.info(`Starting TS Server`); - logger.info(`Version: ${versionMajorMinor}`); + logger.info(`Version: ${version}`); logger.info(`Arguments: ${process.argv.join(" ")}`); + logger.info(`Platform: ${os.platform()} NodeVersion: ${nodeVersion} CaseSensitive: ${sys.useCaseSensitiveFileNames}`); const ioSession = new IOSession(options); process.on("uncaughtException", err => {