From 4e56347d58a56865614d5f50f11b08c44744166a Mon Sep 17 00:00:00 2001 From: Sheetal Nandi Date: Mon, 23 Oct 2017 19:05:38 -0700 Subject: [PATCH] Set the files found during node_modules search correctly when reusing existing program structure This marks files reused correctly as from external library resulting in not using them for files to be emitted and computed for output structure Fixes #19327 --- src/compiler/program.ts | 4 ++++ src/harness/unittests/tscWatchMode.ts | 1 + 2 files changed, 5 insertions(+) diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 1d325983f5f..0ff78a77ecd 100755 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1049,6 +1049,10 @@ namespace ts { // update fileName -> file mapping for (let i = 0; i < newSourceFiles.length; i++) { filesByName.set(filePaths[i], newSourceFiles[i]); + // Set the file as found during node modules search if it was found that way in old progra, + if (oldProgram.isSourceFileFromExternalLibrary(oldProgram.getSourceFileByPath(filePaths[i]))) { + sourceFilesFoundSearchingNodeModules.set(filePaths[i], true); + } } files = newSourceFiles; diff --git a/src/harness/unittests/tscWatchMode.ts b/src/harness/unittests/tscWatchMode.ts index 10ed8ea8da3..c5aba73f2ac 100644 --- a/src/harness/unittests/tscWatchMode.ts +++ b/src/harness/unittests/tscWatchMode.ts @@ -1927,6 +1927,7 @@ declare module "fs" { expectedFiles[1].isExpectedToEmit = false; host.reloadFS(programFiles.concat(configFile)); host.runQueuedTimeoutCallbacks(); + checkProgramActualFiles(watch(), programFiles.map(f => f.path)); checkOutputErrors(host, emptyArray); verifyExpectedFiles(expectedFiles);