typescript 4.7.0-dev.20220419 → 4.7.0-dev.20220422

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.
package/lib/tsc.js CHANGED
@@ -69,7 +69,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
69
69
  var ts;
70
70
  (function (ts) {
71
71
  ts.versionMajorMinor = "4.7";
72
- ts.version = ts.versionMajorMinor + ".0-dev.20220419";
72
+ ts.version = ts.versionMajorMinor + ".0-dev.20220422";
73
73
  var NativeCollections;
74
74
  (function (NativeCollections) {
75
75
  var globals = typeof globalThis !== "undefined" ? globalThis :
@@ -14324,10 +14324,10 @@ var ts;
14324
14324
  return ts.combinePaths(newDirPath, sourceFilePath);
14325
14325
  }
14326
14326
  ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
14327
- function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
14328
- host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
14327
+ function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
14328
+ host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
14329
14329
  diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
14330
- }, sourceFiles);
14330
+ }, sourceFiles, data);
14331
14331
  }
14332
14332
  ts.writeFile = writeFile;
14333
14333
  function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
@@ -61316,6 +61316,7 @@ var ts;
61316
61316
  }
61317
61317
  }
61318
61318
  else {
61319
+ error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
61319
61320
  typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
61320
61321
  }
61321
61322
  }
@@ -62000,7 +62001,9 @@ var ts;
62000
62001
  }
62001
62002
  prop = getPropertyOfType(apparentType, right.escapedText);
62002
62003
  }
62003
- if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
62004
+ if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
62005
+ !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 && node.parent.kind === 299)) ||
62006
+ ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
62004
62007
  markAliasReferenced(parentSymbol, node);
62005
62008
  }
62006
62009
  var propType;
@@ -72130,15 +72133,14 @@ var ts;
72130
72133
  return propertyDeclaration;
72131
72134
  }
72132
72135
  }
72133
- else if (ts.isMetaProperty(parent)) {
72134
- var parentType = getTypeOfNode(parent);
72135
- var propertyDeclaration = getPropertyOfType(parentType, node.escapedText);
72136
- if (propertyDeclaration) {
72137
- return propertyDeclaration;
72138
- }
72139
- if (parent.keywordToken === 103) {
72136
+ else if (ts.isMetaProperty(parent) && parent.name === node) {
72137
+ if (parent.keywordToken === 103 && ts.idText(node) === "target") {
72140
72138
  return checkNewTargetMetaProperty(parent).symbol;
72141
72139
  }
72140
+ if (parent.keywordToken === 100 && ts.idText(node) === "meta") {
72141
+ return getGlobalImportMetaExpressionType().members.get("meta");
72142
+ }
72143
+ return undefined;
72142
72144
  }
72143
72145
  }
72144
72146
  switch (node.kind) {
@@ -79084,7 +79086,7 @@ var ts;
79084
79086
  }
79085
79087
  resumeLexicalEnvironment();
79086
79088
  var needsSyntheticConstructor = !constructor && isDerivedClass;
79087
- var indexOfFirstStatementAfterSuper = 0;
79089
+ var indexOfFirstStatementAfterSuperAndPrologue = 0;
79088
79090
  var prologueStatementCount = 0;
79089
79091
  var superStatementIndex = -1;
79090
79092
  var statements = [];
@@ -79092,8 +79094,11 @@ var ts;
79092
79094
  prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, false, visitor);
79093
79095
  superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
79094
79096
  if (superStatementIndex >= 0) {
79095
- indexOfFirstStatementAfterSuper = superStatementIndex + 1;
79096
- 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);
79097
+ indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
79098
+ 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);
79099
+ }
79100
+ else if (prologueStatementCount >= 0) {
79101
+ indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
79097
79102
  }
79098
79103
  }
79099
79104
  if (needsSyntheticConstructor) {
@@ -79112,19 +79117,17 @@ var ts;
79112
79117
  }
79113
79118
  }
79114
79119
  if (parameterPropertyDeclarationCount > 0) {
79115
- var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
79120
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
79116
79121
  if (superStatementIndex >= 0) {
79117
79122
  ts.addRange(statements, parameterProperties);
79118
79123
  }
79119
- else if (needsSyntheticConstructor) {
79120
- statements = __spreadArray(__spreadArray([
79121
- statements[0]
79122
- ], parameterProperties, true), statements.slice(1), true);
79123
- }
79124
79124
  else {
79125
- statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
79125
+ var superAndPrologueStatementCount = prologueStatementCount;
79126
+ if (needsSyntheticConstructor)
79127
+ superAndPrologueStatementCount++;
79128
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
79126
79129
  }
79127
- indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
79130
+ indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
79128
79131
  }
79129
79132
  }
79130
79133
  }
@@ -79132,7 +79135,7 @@ var ts;
79132
79135
  addMethodStatements(statements, privateMethodsAndAccessors, receiver);
79133
79136
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
79134
79137
  if (constructor) {
79135
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
79138
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
79136
79139
  }
79137
79140
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
79138
79141
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements), constructor ? constructor.body.statements : node.members), true), constructor ? constructor.body : undefined);
@@ -82352,7 +82355,7 @@ var ts;
82352
82355
  else {
82353
82356
  insertCaptureThisForNodeIfNeeded(prologue, constructor);
82354
82357
  }
82355
- var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex)), true), statements, true)), constructor.body.statements), true);
82358
+ var body = factory.createBlock(ts.setTextRange(factory.createNodeArray(__spreadArray(__spreadArray(__spreadArray(__spreadArray([], existingPrologue, true), prologue, true), (superStatementIndex <= existingPrologue.length ? ts.emptyArray : ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), true), statements, true)), constructor.body.statements), true);
82356
82359
  ts.setTextRange(body, constructor.body);
82357
82360
  return body;
82358
82361
  }
@@ -90211,6 +90214,7 @@ var ts;
90211
90214
  else {
90212
90215
  printer.writeFile(sourceFile, writer, sourceMapGenerator);
90213
90216
  }
90217
+ var sourceMapUrlPos;
90214
90218
  if (sourceMapGenerator) {
90215
90219
  if (sourceMapDataList) {
90216
90220
  sourceMapDataList.push({
@@ -90222,6 +90226,7 @@ var ts;
90222
90226
  if (sourceMappingURL) {
90223
90227
  if (!writer.isAtStartOfLine())
90224
90228
  writer.rawWrite(newLine);
90229
+ sourceMapUrlPos = writer.getTextPos();
90225
90230
  writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL);
90226
90231
  }
90227
90232
  if (sourceMapFilePath) {
@@ -90232,7 +90237,7 @@ var ts;
90232
90237
  else {
90233
90238
  writer.writeLine();
90234
90239
  }
90235
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
90240
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
90236
90241
  writer.clear();
90237
90242
  }
90238
90243
  function shouldEmitSourceMaps(mapOptions, sourceFileOrBundle) {
@@ -95204,7 +95209,11 @@ var ts;
95204
95209
  return newValue;
95205
95210
  };
95206
95211
  if (originalWriteFile) {
95207
- host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
95212
+ host.writeFile = function (fileName, data) {
95213
+ var rest = [];
95214
+ for (var _i = 2; _i < arguments.length; _i++) {
95215
+ rest[_i - 2] = arguments[_i];
95216
+ }
95208
95217
  var key = toPath(fileName);
95209
95218
  fileExistsCache.delete(key);
95210
95219
  var value = readFileCache.get(key);
@@ -95218,7 +95227,7 @@ var ts;
95218
95227
  sourceFileCache.delete(key);
95219
95228
  }
95220
95229
  }
95221
- originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
95230
+ originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
95222
95231
  };
95223
95232
  }
95224
95233
  if (originalDirectoryExists && originalCreateDirectory) {
@@ -96040,6 +96049,7 @@ var ts;
96040
96049
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
96041
96050
  getFileIncludeReasons: function () { return fileReasons; },
96042
96051
  structureIsReused: structureIsReused,
96052
+ writeFile: writeFile,
96043
96053
  };
96044
96054
  onProgramCreateComplete();
96045
96055
  fileProcessingDiagnostics === null || fileProcessingDiagnostics === void 0 ? void 0 : fileProcessingDiagnostics.forEach(function (diagnostic) {
@@ -96443,7 +96453,7 @@ var ts;
96443
96453
  getProjectReferenceRedirect: getProjectReferenceRedirect,
96444
96454
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
96445
96455
  getSymlinkCache: getSymlinkCache,
96446
- writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
96456
+ writeFile: writeFileCallback || writeFile,
96447
96457
  isEmitBlocked: isEmitBlocked,
96448
96458
  readFile: function (f) { return host.readFile(f); },
96449
96459
  fileExists: function (f) {
@@ -96461,6 +96471,9 @@ var ts;
96461
96471
  getFileIncludeReasons: program.getFileIncludeReasons,
96462
96472
  };
96463
96473
  }
96474
+ function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
96475
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
96476
+ }
96464
96477
  function emitBuildInfo(writeFileCallback) {
96465
96478
  ts.Debug.assert(!ts.outFile(options));
96466
96479
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit", "emitBuildInfo", {}, true);
@@ -98638,6 +98651,7 @@ var ts;
98638
98651
  }
98639
98652
  }
98640
98653
  }
98654
+ BuilderState.updateExportedModules = updateExportedModules;
98641
98655
  function updateExportedFilesMapFromCache(state, exportedModulesMapCache) {
98642
98656
  var _a;
98643
98657
  if (exportedModulesMapCache) {
@@ -98964,29 +98978,30 @@ var ts;
98964
98978
  }
98965
98979
  return undefined;
98966
98980
  }
98981
+ function removeDiagnosticsOfLibraryFiles(state) {
98982
+ if (!state.cleanedDiagnosticsOfLibFiles) {
98983
+ state.cleanedDiagnosticsOfLibFiles = true;
98984
+ var program_1 = ts.Debug.checkDefined(state.program);
98985
+ var options_2 = program_1.getCompilerOptions();
98986
+ ts.forEach(program_1.getSourceFiles(), function (f) {
98987
+ return program_1.isSourceFileDefaultLibrary(f) &&
98988
+ !ts.skipTypeChecking(f, options_2, program_1) &&
98989
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
98990
+ });
98991
+ }
98992
+ }
98967
98993
  function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
98968
98994
  var _a;
98969
98995
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
98970
98996
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
98971
- if (!state.cleanedDiagnosticsOfLibFiles) {
98972
- state.cleanedDiagnosticsOfLibFiles = true;
98973
- var program_1 = ts.Debug.checkDefined(state.program);
98974
- var options_2 = program_1.getCompilerOptions();
98975
- ts.forEach(program_1.getSourceFiles(), function (f) {
98976
- return program_1.isSourceFileDefaultLibrary(f) &&
98977
- !ts.skipTypeChecking(f, options_2, program_1) &&
98978
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
98979
- });
98980
- }
98997
+ removeDiagnosticsOfLibraryFiles(state);
98981
98998
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
98982
98999
  return;
98983
99000
  }
98984
- else {
98985
- 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);
98986
- }
98987
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
98988
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
98989
- }
99001
+ 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);
99002
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
99003
+ return;
99004
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
98990
99005
  }
98991
99006
  function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
98992
99007
  removeSemanticDiagnosticsOf(state, path);
@@ -99014,11 +99029,32 @@ var ts;
99014
99029
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
99015
99030
  return newSignature !== oldSignature;
99016
99031
  }
99017
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
99018
- var _a, _b;
99019
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
99032
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
99033
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
99034
+ var result = keys && ts.forEachKey(keys, fn);
99035
+ if (result)
99036
+ return result;
99037
+ keys = state.exportedModulesMap.getKeys(filePath);
99038
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
99039
+ var _a;
99040
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99041
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
99042
+ fn(exportedFromPath) :
99043
+ undefined;
99044
+ });
99045
+ }
99046
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
99047
+ var _a;
99048
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
99049
+ return false;
99050
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, undefined)
99051
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
99052
+ removeDiagnosticsOfLibraryFiles(state);
99053
+ return true;
99054
+ }
99055
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
99056
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
99020
99057
  return;
99021
- }
99022
99058
  if (!isChangedSignature(state, affectedFile.resolvedPath))
99023
99059
  return;
99024
99060
  if (state.compilerOptions.isolatedModules) {
@@ -99029,7 +99065,9 @@ var ts;
99029
99065
  var currentPath = queue.pop();
99030
99066
  if (!seenFileNamesMap.has(currentPath)) {
99031
99067
  seenFileNamesMap.set(currentPath, true);
99032
- fn(state, currentPath);
99068
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
99069
+ return;
99070
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
99033
99071
  if (isChangedSignature(state, currentPath)) {
99034
99072
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
99035
99073
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -99039,42 +99077,31 @@ var ts;
99039
99077
  }
99040
99078
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
99041
99079
  var seenFileAndExportsOfFile = new ts.Set();
99042
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
99043
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99044
- });
99045
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
99046
- var _a;
99047
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99048
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
99049
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99080
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
99081
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
99082
+ return true;
99083
+ var references = state.referencedMap.getKeys(exportedFromPath);
99084
+ return references && ts.forEachKey(references, function (filePath) {
99085
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99086
+ });
99050
99087
  });
99051
99088
  }
99052
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
99089
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
99053
99090
  var _a;
99054
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
99055
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
99056
- });
99057
- }
99058
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
99059
- var _a, _b, _c;
99060
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
99061
- return;
99062
- }
99063
- fn(state, filePath);
99091
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
99092
+ return undefined;
99093
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
99094
+ return true;
99095
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
99064
99096
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
99065
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
99066
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99067
- });
99068
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
99069
- var _a;
99070
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
99071
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
99072
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
99097
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
99098
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
99073
99099
  });
99074
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
99100
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
99075
99101
  return !seenFileAndExportsOfFile.has(referencingFilePath) &&
99076
- fn(state, referencingFilePath);
99102
+ handleDtsMayChangeOf(state, referencingFilePath, cancellationToken, computeHash, host);
99077
99103
  });
99104
+ return undefined;
99078
99105
  }
99079
99106
  function doneWithAffectedFile(state, affected, emitKind, isPendingEmit, isBuildInfoEmit) {
99080
99107
  if (isBuildInfoEmit) {
@@ -99396,7 +99423,43 @@ var ts;
99396
99423
  affected = program;
99397
99424
  }
99398
99425
  }
99399
- return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile);
99426
+ return toAffectedFileEmitResult(state, ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
99427
+ getWriteFileUpdatingSignatureCallback(writeFile) :
99428
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0, customTransformers), affected, emitKind, isPendingEmitFile);
99429
+ }
99430
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
99431
+ return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
99432
+ var _a;
99433
+ if (ts.isDeclarationFileName(fileName)) {
99434
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
99435
+ var file = sourceFiles[0];
99436
+ var info = state.fileInfos.get(file.resolvedPath);
99437
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
99438
+ if (signature === file.version) {
99439
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
99440
+ if (newSignature !== file.version) {
99441
+ if (host.storeFilesChangingSignatureDuringEmit)
99442
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
99443
+ if (state.exportedModulesMap)
99444
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
99445
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
99446
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
99447
+ }
99448
+ else {
99449
+ info.signature = newSignature;
99450
+ if (state.exportedModulesMap)
99451
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
99452
+ }
99453
+ }
99454
+ }
99455
+ }
99456
+ if (writeFile)
99457
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99458
+ else if (host.writeFile)
99459
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99460
+ else
99461
+ state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
99462
+ };
99400
99463
  }
99401
99464
  function emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
99402
99465
  var _a;
@@ -99437,7 +99500,9 @@ var ts;
99437
99500
  }
99438
99501
  }
99439
99502
  }
99440
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
99503
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
99504
+ getWriteFileUpdatingSignatureCallback(writeFile) :
99505
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
99441
99506
  }
99442
99507
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
99443
99508
  while (true) {
@@ -101360,6 +101425,7 @@ var ts;
101360
101425
  createHash: ts.maybeBind(host, host.createHash),
101361
101426
  readDirectory: ts.maybeBind(host, host.readDirectory),
101362
101427
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
101428
+ storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
101363
101429
  };
101364
101430
  function writeFile(fileName, text, writeByteOrderMark, onError) {
101365
101431
  try {
@@ -101413,6 +101479,7 @@ var ts;
101413
101479
  createHash: ts.maybeBind(system, system.createHash),
101414
101480
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
101415
101481
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
101482
+ storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
101416
101483
  };
101417
101484
  }
101418
101485
  ts.createProgramHost = createProgramHost;
@@ -101489,6 +101556,7 @@ var ts;
101489
101556
  var host = ts.createCompilerHostWorker(options, undefined, system);
101490
101557
  host.createHash = ts.maybeBind(system, system.createHash);
101491
101558
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
101559
+ host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
101492
101560
  ts.setGetSourceFileAsHashVersioned(host, system);
101493
101561
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
101494
101562
  return host;