Merge pull request #31685 from uniqueiniquity/stopInvalidatingOnOpenFileSave

Stop invalidating module resolution cache when saving an open file
This commit is contained in:
Benjamin Lichtman
2019-05-31 20:36:33 -04:00
committed by GitHub
7 changed files with 70 additions and 2 deletions

View File

@@ -54,6 +54,7 @@ namespace ts {
writeLog(s: string): void;
maxNumberOfFilesToIterateForInvalidation?: number;
getCurrentProgram(): Program | undefined;
fileIsOpen(filePath: Path): boolean;
}
interface DirectoryWatchesOfFailedLookup {
@@ -698,6 +699,11 @@ namespace ts {
// If something to do with folder/file starting with "." in node_modules folder, skip it
if (isPathIgnored(fileOrDirectoryPath)) return false;
// prevent saving an open file from over-eagerly triggering invalidation
if (resolutionHost.fileIsOpen(fileOrDirectoryPath)) {
return false;
}
// Some file or directory in the watching directory is created
// Return early if it does not have any of the watching extension or not the custom failed lookup path
const dirOfFileOrDirectory = getDirectoryPath(fileOrDirectoryPath);

View File

@@ -691,6 +691,7 @@ namespace ts {
hasChangedAutomaticTypeDirectiveNames = true;
scheduleProgramUpdate();
};
compilerHost.fileIsOpen = returnFalse;
compilerHost.maxNumberOfFilesToIterateForInvalidation = host.maxNumberOfFilesToIterateForInvalidation;
compilerHost.getCurrentProgram = getCurrentProgram;
compilerHost.writeLog = writeLog;