typescript 4.7.0-dev.20220420 → 4.7.0-dev.20220421

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220420";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220421";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -94890,7 +94890,7 @@ var ts;
94890
94890
  }
94891
94891
  resumeLexicalEnvironment();
94892
94892
  var needsSyntheticConstructor = !constructor && isDerivedClass;
94893
- var indexOfFirstStatementAfterSuper = 0;
94893
+ var indexOfFirstStatementAfterSuperAndPrologue = 0;
94894
94894
  var prologueStatementCount = 0;
94895
94895
  var superStatementIndex = -1;
94896
94896
  var statements = [];
@@ -94899,8 +94899,11 @@ var ts;
94899
94899
  superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
94900
94900
  // If there was a super call, visit existing statements up to and including it
94901
94901
  if (superStatementIndex >= 0) {
94902
- indexOfFirstStatementAfterSuper = superStatementIndex + 1;
94903
- statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
94902
+ indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
94903
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
94904
+ }
94905
+ else if (prologueStatementCount >= 0) {
94906
+ indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
94904
94907
  }
94905
94908
  }
94906
94909
  if (needsSyntheticConstructor) {
@@ -94936,22 +94939,20 @@ var ts;
94936
94939
  }
94937
94940
  }
94938
94941
  if (parameterPropertyDeclarationCount > 0) {
94939
- var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
94942
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
94940
94943
  // If there was a super() call found, add parameter properties immediately after it
94941
94944
  if (superStatementIndex >= 0) {
94942
94945
  ts.addRange(statements, parameterProperties);
94943
94946
  }
94944
- // If a synthetic super() call was added, add them just after it
94945
- else if (needsSyntheticConstructor) {
94946
- statements = __spreadArray(__spreadArray([
94947
- statements[0]
94948
- ], parameterProperties, true), statements.slice(1), true);
94949
- }
94950
- // Since there wasn't a super() call, add them to the top of the constructor
94951
94947
  else {
94952
- statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
94948
+ // Add add parameter properties to the top of the constructor after the prologue
94949
+ var superAndPrologueStatementCount = prologueStatementCount;
94950
+ // If a synthetic super() call was added, need to account for that
94951
+ if (needsSyntheticConstructor)
94952
+ superAndPrologueStatementCount++;
94953
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
94953
94954
  }
94954
- indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
94955
+ indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
94955
94956
  }
94956
94957
  }
94957
94958
  }
@@ -94961,7 +94962,7 @@ var ts;
94961
94962
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
94962
94963
  // Add existing statements after the initial prologues and super call
94963
94964
  if (constructor) {
94964
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
94965
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
94965
94966
  }
94966
94967
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
94967
94968
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
@@ -119978,6 +119979,18 @@ var ts;
119978
119979
  }
119979
119980
  return undefined;
119980
119981
  }
119982
+ function removeDiagnosticsOfLibraryFiles(state) {
119983
+ if (!state.cleanedDiagnosticsOfLibFiles) {
119984
+ state.cleanedDiagnosticsOfLibFiles = true;
119985
+ var program_1 = ts.Debug.checkDefined(state.program);
119986
+ var options_2 = program_1.getCompilerOptions();
119987
+ ts.forEach(program_1.getSourceFiles(), function (f) {
119988
+ return program_1.isSourceFileDefaultLibrary(f) &&
119989
+ !ts.skipTypeChecking(f, options_2, program_1) &&
119990
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
119991
+ });
119992
+ }
119993
+ }
119981
119994
  /**
119982
119995
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119983
119996
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
@@ -119987,28 +120000,17 @@ var ts;
119987
120000
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119988
120001
  // If affected files is everything except default library, then nothing more to do
119989
120002
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
119990
- if (!state.cleanedDiagnosticsOfLibFiles) {
119991
- state.cleanedDiagnosticsOfLibFiles = true;
119992
- var program_1 = ts.Debug.checkDefined(state.program);
119993
- var options_2 = program_1.getCompilerOptions();
119994
- ts.forEach(program_1.getSourceFiles(), function (f) {
119995
- return program_1.isSourceFileDefaultLibrary(f) &&
119996
- !ts.skipTypeChecking(f, options_2, program_1) &&
119997
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
119998
- });
119999
- }
120003
+ removeDiagnosticsOfLibraryFiles(state);
120000
120004
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120001
120005
  // That means when affected file is handled, its signature can be out of date
120002
120006
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120003
120007
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120004
120008
  return;
120005
120009
  }
120006
- else {
120007
- ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
120008
- }
120009
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
120010
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
120011
- }
120010
+ ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
120011
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120012
+ return;
120013
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
120012
120014
  }
120013
120015
  /**
120014
120016
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
@@ -120050,16 +120052,41 @@ var ts;
120050
120052
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120051
120053
  return newSignature !== oldSignature;
120052
120054
  }
120055
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120056
+ // Go through exported modules from cache first
120057
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120058
+ var result = keys && ts.forEachKey(keys, fn);
120059
+ if (result)
120060
+ return result;
120061
+ // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120062
+ keys = state.exportedModulesMap.getKeys(filePath);
120063
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
120064
+ var _a;
120065
+ // If the cache had an updated value, skip
120066
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120067
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120068
+ fn(exportedFromPath) :
120069
+ undefined;
120070
+ });
120071
+ }
120072
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120073
+ var _a;
120074
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
120075
+ return false;
120076
+ // Every file needs to be handled
120077
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
120078
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
120079
+ removeDiagnosticsOfLibraryFiles(state);
120080
+ return true;
120081
+ }
120053
120082
  /**
120054
- * Iterate on referencing modules that export entities from affected file
120083
+ * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120055
120084
  */
120056
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
120057
- var _a, _b;
120085
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120058
120086
  // If there was change in signature (dts output) for the changed file,
120059
120087
  // then only we need to handle pending file emit
120060
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
120088
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
120061
120089
  return;
120062
- }
120063
120090
  if (!isChangedSignature(state, affectedFile.resolvedPath))
120064
120091
  return;
120065
120092
  // Since isolated modules dont change js files, files affected by change in signature is itself
@@ -120072,7 +120099,9 @@ var ts;
120072
120099
  var currentPath = queue.pop();
120073
120100
  if (!seenFileNamesMap.has(currentPath)) {
120074
120101
  seenFileNamesMap.set(currentPath, true);
120075
- fn(state, currentPath);
120102
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
120103
+ return;
120104
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
120076
120105
  if (isChangedSignature(state, currentPath)) {
120077
120106
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
120078
120107
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -120084,56 +120113,38 @@ var ts;
120084
120113
  var seenFileAndExportsOfFile = new ts.Set();
120085
120114
  // Go through exported modules from cache first
120086
120115
  // If exported modules has path, all files referencing file exported from are affected
120087
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120088
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120089
- });
120090
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120091
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
120092
- var _a;
120093
- // If the cache had an updated value, skip
120094
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120095
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
120096
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120116
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120117
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120118
+ return true;
120119
+ var references = state.referencedMap.getKeys(exportedFromPath);
120120
+ return references && ts.forEachKey(references, function (filePath) {
120121
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120122
+ });
120097
120123
  });
120098
120124
  }
120099
120125
  /**
120100
- * Iterate on files referencing referencedPath
120126
+ * handle dts and semantic diagnostics on file and iterate on anything that exports this file
120127
+ * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120101
120128
  */
120102
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
120129
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120103
120130
  var _a;
120104
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
120105
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
120106
- });
120107
- }
120108
- /**
120109
- * fn on file and iterate on anything that exports this file
120110
- */
120111
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
120112
- var _a, _b, _c;
120113
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
120114
- return;
120115
- }
120116
- fn(state, filePath);
120131
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120132
+ return undefined;
120133
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120134
+ return true;
120135
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120117
120136
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120118
- // Go through exported modules from cache first
120119
120137
  // If exported modules has path, all files referencing file exported from are affected
120120
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120121
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120122
- });
120123
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120124
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
120125
- var _a;
120126
- // If the cache had an updated value, skip
120127
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120128
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
120129
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120138
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
120139
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120130
120140
  });
120131
120141
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120132
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
120142
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
120133
120143
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120134
- fn(state, referencingFilePath);
120135
- } // Dont add to seen since this is not yet done with the export removal
120136
- );
120144
+ handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120145
+ state, referencingFilePath, cancellationToken, computeHash, host);
120146
+ });
120147
+ return undefined;
120137
120148
  }
120138
120149
  /**
120139
120150
  * This is called after completing operation on the next affected file.
package/lib/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220420";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220421";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -94890,7 +94890,7 @@ var ts;
94890
94890
  }
94891
94891
  resumeLexicalEnvironment();
94892
94892
  var needsSyntheticConstructor = !constructor && isDerivedClass;
94893
- var indexOfFirstStatementAfterSuper = 0;
94893
+ var indexOfFirstStatementAfterSuperAndPrologue = 0;
94894
94894
  var prologueStatementCount = 0;
94895
94895
  var superStatementIndex = -1;
94896
94896
  var statements = [];
@@ -94899,8 +94899,11 @@ var ts;
94899
94899
  superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
94900
94900
  // If there was a super call, visit existing statements up to and including it
94901
94901
  if (superStatementIndex >= 0) {
94902
- indexOfFirstStatementAfterSuper = superStatementIndex + 1;
94903
- statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
94902
+ indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
94903
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
94904
+ }
94905
+ else if (prologueStatementCount >= 0) {
94906
+ indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
94904
94907
  }
94905
94908
  }
94906
94909
  if (needsSyntheticConstructor) {
@@ -94936,22 +94939,20 @@ var ts;
94936
94939
  }
94937
94940
  }
94938
94941
  if (parameterPropertyDeclarationCount > 0) {
94939
- var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
94942
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
94940
94943
  // If there was a super() call found, add parameter properties immediately after it
94941
94944
  if (superStatementIndex >= 0) {
94942
94945
  ts.addRange(statements, parameterProperties);
94943
94946
  }
94944
- // If a synthetic super() call was added, add them just after it
94945
- else if (needsSyntheticConstructor) {
94946
- statements = __spreadArray(__spreadArray([
94947
- statements[0]
94948
- ], parameterProperties, true), statements.slice(1), true);
94949
- }
94950
- // Since there wasn't a super() call, add them to the top of the constructor
94951
94947
  else {
94952
- statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
94948
+ // Add add parameter properties to the top of the constructor after the prologue
94949
+ var superAndPrologueStatementCount = prologueStatementCount;
94950
+ // If a synthetic super() call was added, need to account for that
94951
+ if (needsSyntheticConstructor)
94952
+ superAndPrologueStatementCount++;
94953
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
94953
94954
  }
94954
- indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
94955
+ indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
94955
94956
  }
94956
94957
  }
94957
94958
  }
@@ -94961,7 +94962,7 @@ var ts;
94961
94962
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
94962
94963
  // Add existing statements after the initial prologues and super call
94963
94964
  if (constructor) {
94964
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
94965
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
94965
94966
  }
94966
94967
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
94967
94968
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
@@ -119978,6 +119979,18 @@ var ts;
119978
119979
  }
119979
119980
  return undefined;
119980
119981
  }
119982
+ function removeDiagnosticsOfLibraryFiles(state) {
119983
+ if (!state.cleanedDiagnosticsOfLibFiles) {
119984
+ state.cleanedDiagnosticsOfLibFiles = true;
119985
+ var program_1 = ts.Debug.checkDefined(state.program);
119986
+ var options_2 = program_1.getCompilerOptions();
119987
+ ts.forEach(program_1.getSourceFiles(), function (f) {
119988
+ return program_1.isSourceFileDefaultLibrary(f) &&
119989
+ !ts.skipTypeChecking(f, options_2, program_1) &&
119990
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
119991
+ });
119992
+ }
119993
+ }
119981
119994
  /**
119982
119995
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119983
119996
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
@@ -119987,28 +120000,17 @@ var ts;
119987
120000
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119988
120001
  // If affected files is everything except default library, then nothing more to do
119989
120002
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
119990
- if (!state.cleanedDiagnosticsOfLibFiles) {
119991
- state.cleanedDiagnosticsOfLibFiles = true;
119992
- var program_1 = ts.Debug.checkDefined(state.program);
119993
- var options_2 = program_1.getCompilerOptions();
119994
- ts.forEach(program_1.getSourceFiles(), function (f) {
119995
- return program_1.isSourceFileDefaultLibrary(f) &&
119996
- !ts.skipTypeChecking(f, options_2, program_1) &&
119997
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
119998
- });
119999
- }
120003
+ removeDiagnosticsOfLibraryFiles(state);
120000
120004
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120001
120005
  // That means when affected file is handled, its signature can be out of date
120002
120006
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120003
120007
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120004
120008
  return;
120005
120009
  }
120006
- else {
120007
- ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
120008
- }
120009
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
120010
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
120011
- }
120010
+ ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
120011
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120012
+ return;
120013
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
120012
120014
  }
120013
120015
  /**
120014
120016
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
@@ -120050,16 +120052,41 @@ var ts;
120050
120052
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120051
120053
  return newSignature !== oldSignature;
120052
120054
  }
120055
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120056
+ // Go through exported modules from cache first
120057
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120058
+ var result = keys && ts.forEachKey(keys, fn);
120059
+ if (result)
120060
+ return result;
120061
+ // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120062
+ keys = state.exportedModulesMap.getKeys(filePath);
120063
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
120064
+ var _a;
120065
+ // If the cache had an updated value, skip
120066
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120067
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120068
+ fn(exportedFromPath) :
120069
+ undefined;
120070
+ });
120071
+ }
120072
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120073
+ var _a;
120074
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
120075
+ return false;
120076
+ // Every file needs to be handled
120077
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
120078
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
120079
+ removeDiagnosticsOfLibraryFiles(state);
120080
+ return true;
120081
+ }
120053
120082
  /**
120054
- * Iterate on referencing modules that export entities from affected file
120083
+ * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120055
120084
  */
120056
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
120057
- var _a, _b;
120085
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120058
120086
  // If there was change in signature (dts output) for the changed file,
120059
120087
  // then only we need to handle pending file emit
120060
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
120088
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
120061
120089
  return;
120062
- }
120063
120090
  if (!isChangedSignature(state, affectedFile.resolvedPath))
120064
120091
  return;
120065
120092
  // Since isolated modules dont change js files, files affected by change in signature is itself
@@ -120072,7 +120099,9 @@ var ts;
120072
120099
  var currentPath = queue.pop();
120073
120100
  if (!seenFileNamesMap.has(currentPath)) {
120074
120101
  seenFileNamesMap.set(currentPath, true);
120075
- fn(state, currentPath);
120102
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
120103
+ return;
120104
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
120076
120105
  if (isChangedSignature(state, currentPath)) {
120077
120106
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
120078
120107
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -120084,56 +120113,38 @@ var ts;
120084
120113
  var seenFileAndExportsOfFile = new ts.Set();
120085
120114
  // Go through exported modules from cache first
120086
120115
  // If exported modules has path, all files referencing file exported from are affected
120087
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120088
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120089
- });
120090
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120091
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
120092
- var _a;
120093
- // If the cache had an updated value, skip
120094
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120095
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
120096
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120116
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120117
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120118
+ return true;
120119
+ var references = state.referencedMap.getKeys(exportedFromPath);
120120
+ return references && ts.forEachKey(references, function (filePath) {
120121
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120122
+ });
120097
120123
  });
120098
120124
  }
120099
120125
  /**
120100
- * Iterate on files referencing referencedPath
120126
+ * handle dts and semantic diagnostics on file and iterate on anything that exports this file
120127
+ * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120101
120128
  */
120102
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
120129
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120103
120130
  var _a;
120104
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
120105
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
120106
- });
120107
- }
120108
- /**
120109
- * fn on file and iterate on anything that exports this file
120110
- */
120111
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
120112
- var _a, _b, _c;
120113
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
120114
- return;
120115
- }
120116
- fn(state, filePath);
120131
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120132
+ return undefined;
120133
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120134
+ return true;
120135
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120117
120136
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120118
- // Go through exported modules from cache first
120119
120137
  // If exported modules has path, all files referencing file exported from are affected
120120
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120121
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120122
- });
120123
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120124
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
120125
- var _a;
120126
- // If the cache had an updated value, skip
120127
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120128
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
120129
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120138
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
120139
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120130
120140
  });
120131
120141
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120132
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
120142
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
120133
120143
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120134
- fn(state, referencingFilePath);
120135
- } // Dont add to seen since this is not yet done with the export removal
120136
- );
120144
+ handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120145
+ state, referencingFilePath, cancellationToken, computeHash, host);
120146
+ });
120147
+ return undefined;
120137
120148
  }
120138
120149
  /**
120139
120150
  * This is called after completing operation on the next affected file.