More updates to program reuse with different option changes (#44276)

This commit is contained in:
Sheetal Nandi
2021-05-26 15:57:43 -07:00
committed by GitHub
parent 3442d311cf
commit 2ffd35de4d
6 changed files with 27 additions and 22 deletions

View File

@@ -745,9 +745,7 @@ namespace ts {
if (!program) return false;
// If any compiler options change, we can't reuse old source file even if version match
// The change in options like these could result in change in syntax tree or `sourceFile.bindDiagnostics`.
const oldOptions = program.getCompilerOptions();
return !!sourceFileAffectingCompilerOptions.some(option =>
!isJsonEqual(getCompilerOptionValue(oldOptions, option), getCompilerOptionValue(newOptions, option)));
return optionsHaveChanges(program.getCompilerOptions(), newOptions, sourceFileAffectingCompilerOptions);
}
function createCreateProgramOptions(rootNames: readonly string[], options: CompilerOptions, host?: CompilerHost, oldProgram?: Program, configFileParsingDiagnostics?: readonly Diagnostic[]): CreateProgramOptions {
@@ -1421,10 +1419,6 @@ namespace ts {
return StructureIsReused.Not;
}
if (!arrayIsEqualTo(options.types, oldOptions.types)) {
return StructureIsReused.Not;
}
// Check if any referenced project tsconfig files are different
if (!canReuseProjectReferences()) {
return StructureIsReused.Not;
@@ -1505,7 +1499,7 @@ namespace ts {
if (!arrayIsEqualTo(oldSourceFile.libReferenceDirectives, newSourceFile.libReferenceDirectives, fileReferenceIsEqualTo)) {
// 'lib' references has changed. Matches behavior in changesAffectModuleResolution
return StructureIsReused.Not;
structureIsReused = StructureIsReused.SafeModules;
}
if (oldSourceFile.hasNoDefaultLib !== newSourceFile.hasNoDefaultLib) {
@@ -1598,7 +1592,7 @@ namespace ts {
return structureIsReused;
}
if (host.hasChangedAutomaticTypeDirectiveNames?.()) {
if (changesAffectingProgramStructure(oldOptions, options) || host.hasChangedAutomaticTypeDirectiveNames?.()) {
return StructureIsReused.SafeModules;
}