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.
@@ -89,7 +89,7 @@ var ts;
89
89
  // The following is baselined as a literal template type without intervention
90
90
  /** The version of the TypeScript compiler release */
91
91
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
92
- ts.version = ts.versionMajorMinor + ".0-dev.20220419";
92
+ ts.version = ts.versionMajorMinor + ".0-dev.20220422";
93
93
  /* @internal */
94
94
  var Comparison;
95
95
  (function (Comparison) {
@@ -18282,10 +18282,10 @@ var ts;
18282
18282
  return ts.combinePaths(newDirPath, sourceFilePath);
18283
18283
  }
18284
18284
  ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
18285
- function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
18286
- host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
18285
+ function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
18286
+ host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
18287
18287
  diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
18288
- }, sourceFiles);
18288
+ }, sourceFiles, data);
18289
18289
  }
18290
18290
  ts.writeFile = writeFile;
18291
18291
  function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
@@ -73421,6 +73421,7 @@ var ts;
73421
73421
  }
73422
73422
  }
73423
73423
  else {
73424
+ error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
73424
73425
  typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
73425
73426
  }
73426
73427
  }
@@ -74251,10 +74252,15 @@ var ts;
74251
74252
  prop = getPropertyOfType(apparentType, right.escapedText);
74252
74253
  }
74253
74254
  // In `Foo.Bar.Baz`, 'Foo' is not referenced if 'Bar' is a const enum or a module containing only const enums.
74255
+ // `Foo` is also not referenced in `enum FooCopy { Bar = Foo.Bar }`, because the enum member value gets inlined
74256
+ // here even if `Foo` is not a const enum.
74257
+ //
74254
74258
  // The exceptions are:
74255
74259
  // 1. if 'isolatedModules' is enabled, because the const enum value will not be inlined, and
74256
74260
  // 2. if 'preserveConstEnums' is enabled and the expression is itself an export, e.g. `export = Foo.Bar.Baz`.
74257
- if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules || !(prop && isConstEnumOrConstEnumOnlyModule(prop)) || ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
74261
+ if (ts.isIdentifier(left) && parentSymbol && (compilerOptions.isolatedModules ||
74262
+ !(prop && (isConstEnumOrConstEnumOnlyModule(prop) || prop.flags & 8 /* EnumMember */ && node.parent.kind === 299 /* EnumMember */)) ||
74263
+ ts.shouldPreserveConstEnums(compilerOptions) && isExportOrExportExpression(node))) {
74258
74264
  markAliasReferenced(parentSymbol, node);
74259
74265
  }
74260
74266
  var propType;
@@ -85989,15 +85995,20 @@ var ts;
85989
85995
  return propertyDeclaration;
85990
85996
  }
85991
85997
  }
85992
- else if (ts.isMetaProperty(parent)) {
85993
- var parentType = getTypeOfNode(parent);
85994
- var propertyDeclaration = getPropertyOfType(parentType, node.escapedText);
85995
- if (propertyDeclaration) {
85996
- return propertyDeclaration;
85997
- }
85998
- if (parent.keywordToken === 103 /* NewKeyword */) {
85998
+ else if (ts.isMetaProperty(parent) && parent.name === node) {
85999
+ if (parent.keywordToken === 103 /* NewKeyword */ && ts.idText(node) === "target") {
86000
+ // `target` in `new.target`
85999
86001
  return checkNewTargetMetaProperty(parent).symbol;
86000
86002
  }
86003
+ // The `meta` in `import.meta` could be given `getTypeOfNode(parent).symbol` (the `ImportMeta` interface symbol), but
86004
+ // we have a fake expression type made for other reasons already, whose transient `meta`
86005
+ // member should more exactly be the kind of (declarationless) symbol we want.
86006
+ // (See #44364 and #45031 for relevant implementation PRs)
86007
+ if (parent.keywordToken === 100 /* ImportKeyword */ && ts.idText(node) === "meta") {
86008
+ return getGlobalImportMetaExpressionType().members.get("meta");
86009
+ }
86010
+ // no other meta properties are valid syntax, thus no others should have symbols
86011
+ return undefined;
86001
86012
  }
86002
86013
  }
86003
86014
  switch (node.kind) {
@@ -94675,7 +94686,7 @@ var ts;
94675
94686
  }
94676
94687
  resumeLexicalEnvironment();
94677
94688
  var needsSyntheticConstructor = !constructor && isDerivedClass;
94678
- var indexOfFirstStatementAfterSuper = 0;
94689
+ var indexOfFirstStatementAfterSuperAndPrologue = 0;
94679
94690
  var prologueStatementCount = 0;
94680
94691
  var superStatementIndex = -1;
94681
94692
  var statements = [];
@@ -94684,8 +94695,11 @@ var ts;
94684
94695
  superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
94685
94696
  // If there was a super call, visit existing statements up to and including it
94686
94697
  if (superStatementIndex >= 0) {
94687
- indexOfFirstStatementAfterSuper = superStatementIndex + 1;
94688
- 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);
94698
+ indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
94699
+ 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);
94700
+ }
94701
+ else if (prologueStatementCount >= 0) {
94702
+ indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
94689
94703
  }
94690
94704
  }
94691
94705
  if (needsSyntheticConstructor) {
@@ -94721,22 +94735,20 @@ var ts;
94721
94735
  }
94722
94736
  }
94723
94737
  if (parameterPropertyDeclarationCount > 0) {
94724
- var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
94738
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
94725
94739
  // If there was a super() call found, add parameter properties immediately after it
94726
94740
  if (superStatementIndex >= 0) {
94727
94741
  ts.addRange(statements, parameterProperties);
94728
94742
  }
94729
- // If a synthetic super() call was added, add them just after it
94730
- else if (needsSyntheticConstructor) {
94731
- statements = __spreadArray(__spreadArray([
94732
- statements[0]
94733
- ], parameterProperties, true), statements.slice(1), true);
94734
- }
94735
- // Since there wasn't a super() call, add them to the top of the constructor
94736
94743
  else {
94737
- statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
94744
+ // Add add parameter properties to the top of the constructor after the prologue
94745
+ var superAndPrologueStatementCount = prologueStatementCount;
94746
+ // If a synthetic super() call was added, need to account for that
94747
+ if (needsSyntheticConstructor)
94748
+ superAndPrologueStatementCount++;
94749
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
94738
94750
  }
94739
- indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
94751
+ indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
94740
94752
  }
94741
94753
  }
94742
94754
  }
@@ -94746,7 +94758,7 @@ var ts;
94746
94758
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
94747
94759
  // Add existing statements after the initial prologues and super call
94748
94760
  if (constructor) {
94749
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
94761
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
94750
94762
  }
94751
94763
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
94752
94764
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
@@ -98787,7 +98799,7 @@ var ts;
98787
98799
  // ```
98788
98800
  insertCaptureThisForNodeIfNeeded(prologue, constructor);
98789
98801
  }
98790
- 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)),
98802
+ 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)),
98791
98803
  /*location*/ constructor.body.statements),
98792
98804
  /*multiLine*/ true);
98793
98805
  ts.setTextRange(body, constructor.body);
@@ -109944,6 +109956,7 @@ var ts;
109944
109956
  else {
109945
109957
  printer.writeFile(sourceFile, writer, sourceMapGenerator);
109946
109958
  }
109959
+ var sourceMapUrlPos;
109947
109960
  if (sourceMapGenerator) {
109948
109961
  if (sourceMapDataList) {
109949
109962
  sourceMapDataList.push({
@@ -109955,6 +109968,7 @@ var ts;
109955
109968
  if (sourceMappingURL) {
109956
109969
  if (!writer.isAtStartOfLine())
109957
109970
  writer.rawWrite(newLine);
109971
+ sourceMapUrlPos = writer.getTextPos();
109958
109972
  writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment
109959
109973
  }
109960
109974
  // Write the source map
@@ -109967,7 +109981,7 @@ var ts;
109967
109981
  writer.writeLine();
109968
109982
  }
109969
109983
  // Write the output file
109970
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
109984
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
109971
109985
  // Reset state
109972
109986
  writer.clear();
109973
109987
  }
@@ -115434,7 +115448,11 @@ var ts;
115434
115448
  return newValue;
115435
115449
  };
115436
115450
  if (originalWriteFile) {
115437
- host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
115451
+ host.writeFile = function (fileName, data) {
115452
+ var rest = [];
115453
+ for (var _i = 2; _i < arguments.length; _i++) {
115454
+ rest[_i - 2] = arguments[_i];
115455
+ }
115438
115456
  var key = toPath(fileName);
115439
115457
  fileExistsCache.delete(key);
115440
115458
  var value = readFileCache.get(key);
@@ -115448,7 +115466,7 @@ var ts;
115448
115466
  sourceFileCache.delete(key);
115449
115467
  }
115450
115468
  }
115451
- originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
115469
+ originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
115452
115470
  };
115453
115471
  }
115454
115472
  // directoryExists
@@ -116381,6 +116399,7 @@ var ts;
116381
116399
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
116382
116400
  getFileIncludeReasons: function () { return fileReasons; },
116383
116401
  structureIsReused: structureIsReused,
116402
+ writeFile: writeFile,
116384
116403
  };
116385
116404
  onProgramCreateComplete();
116386
116405
  // Add file processingDiagnostics
@@ -116878,7 +116897,7 @@ var ts;
116878
116897
  getProjectReferenceRedirect: getProjectReferenceRedirect,
116879
116898
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
116880
116899
  getSymlinkCache: getSymlinkCache,
116881
- writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
116900
+ writeFile: writeFileCallback || writeFile,
116882
116901
  isEmitBlocked: isEmitBlocked,
116883
116902
  readFile: function (f) { return host.readFile(f); },
116884
116903
  fileExists: function (f) {
@@ -116898,6 +116917,9 @@ var ts;
116898
116917
  getFileIncludeReasons: program.getFileIncludeReasons,
116899
116918
  };
116900
116919
  }
116920
+ function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
116921
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
116922
+ }
116901
116923
  function emitBuildInfo(writeFileCallback) {
116902
116924
  ts.Debug.assert(!ts.outFile(options));
116903
116925
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
@@ -119340,6 +119362,7 @@ var ts;
119340
119362
  }
119341
119363
  }
119342
119364
  }
119365
+ BuilderState.updateExportedModules = updateExportedModules;
119343
119366
  /**
119344
119367
  * Updates the exported modules from cache into state's exported modules map
119345
119368
  * This should be called whenever it is safe to commit the state of the builder
@@ -119763,6 +119786,18 @@ var ts;
119763
119786
  }
119764
119787
  return undefined;
119765
119788
  }
119789
+ function removeDiagnosticsOfLibraryFiles(state) {
119790
+ if (!state.cleanedDiagnosticsOfLibFiles) {
119791
+ state.cleanedDiagnosticsOfLibFiles = true;
119792
+ var program_1 = ts.Debug.checkDefined(state.program);
119793
+ var options_2 = program_1.getCompilerOptions();
119794
+ ts.forEach(program_1.getSourceFiles(), function (f) {
119795
+ return program_1.isSourceFileDefaultLibrary(f) &&
119796
+ !ts.skipTypeChecking(f, options_2, program_1) &&
119797
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
119798
+ });
119799
+ }
119800
+ }
119766
119801
  /**
119767
119802
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119768
119803
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
@@ -119772,28 +119807,17 @@ var ts;
119772
119807
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119773
119808
  // If affected files is everything except default library, then nothing more to do
119774
119809
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
119775
- if (!state.cleanedDiagnosticsOfLibFiles) {
119776
- state.cleanedDiagnosticsOfLibFiles = true;
119777
- var program_1 = ts.Debug.checkDefined(state.program);
119778
- var options_2 = program_1.getCompilerOptions();
119779
- ts.forEach(program_1.getSourceFiles(), function (f) {
119780
- return program_1.isSourceFileDefaultLibrary(f) &&
119781
- !ts.skipTypeChecking(f, options_2, program_1) &&
119782
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
119783
- });
119784
- }
119810
+ removeDiagnosticsOfLibraryFiles(state);
119785
119811
  // When a change affects the global scope, all files are considered to be affected without updating their signature
119786
119812
  // That means when affected file is handled, its signature can be out of date
119787
119813
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
119788
119814
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
119789
119815
  return;
119790
119816
  }
119791
- else {
119792
- 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);
119793
- }
119794
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
119795
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
119796
- }
119817
+ 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);
119818
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
119819
+ return;
119820
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
119797
119821
  }
119798
119822
  /**
119799
119823
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
@@ -119835,16 +119859,41 @@ var ts;
119835
119859
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
119836
119860
  return newSignature !== oldSignature;
119837
119861
  }
119862
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
119863
+ // Go through exported modules from cache first
119864
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
119865
+ var result = keys && ts.forEachKey(keys, fn);
119866
+ if (result)
119867
+ return result;
119868
+ // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
119869
+ keys = state.exportedModulesMap.getKeys(filePath);
119870
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
119871
+ var _a;
119872
+ // If the cache had an updated value, skip
119873
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
119874
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
119875
+ fn(exportedFromPath) :
119876
+ undefined;
119877
+ });
119878
+ }
119879
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
119880
+ var _a;
119881
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
119882
+ return false;
119883
+ // Every file needs to be handled
119884
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
119885
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
119886
+ removeDiagnosticsOfLibraryFiles(state);
119887
+ return true;
119888
+ }
119838
119889
  /**
119839
- * Iterate on referencing modules that export entities from affected file
119890
+ * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
119840
119891
  */
119841
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
119842
- var _a, _b;
119892
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
119843
119893
  // If there was change in signature (dts output) for the changed file,
119844
119894
  // then only we need to handle pending file emit
119845
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
119895
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
119846
119896
  return;
119847
- }
119848
119897
  if (!isChangedSignature(state, affectedFile.resolvedPath))
119849
119898
  return;
119850
119899
  // Since isolated modules dont change js files, files affected by change in signature is itself
@@ -119857,7 +119906,9 @@ var ts;
119857
119906
  var currentPath = queue.pop();
119858
119907
  if (!seenFileNamesMap.has(currentPath)) {
119859
119908
  seenFileNamesMap.set(currentPath, true);
119860
- fn(state, currentPath);
119909
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
119910
+ return;
119911
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
119861
119912
  if (isChangedSignature(state, currentPath)) {
119862
119913
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
119863
119914
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -119869,56 +119920,38 @@ var ts;
119869
119920
  var seenFileAndExportsOfFile = new ts.Set();
119870
119921
  // Go through exported modules from cache first
119871
119922
  // If exported modules has path, all files referencing file exported from are affected
119872
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
119873
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119874
- });
119875
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
119876
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
119877
- var _a;
119878
- // If the cache had an updated value, skip
119879
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
119880
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
119881
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119923
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
119924
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
119925
+ return true;
119926
+ var references = state.referencedMap.getKeys(exportedFromPath);
119927
+ return references && ts.forEachKey(references, function (filePath) {
119928
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
119929
+ });
119882
119930
  });
119883
119931
  }
119884
119932
  /**
119885
- * Iterate on files referencing referencedPath
119933
+ * handle dts and semantic diagnostics on file and iterate on anything that exports this file
119934
+ * return true when all work is done and we can exit handling dts emit and semantic diagnostics
119886
119935
  */
119887
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
119936
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
119888
119937
  var _a;
119889
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
119890
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
119891
- });
119892
- }
119893
- /**
119894
- * fn on file and iterate on anything that exports this file
119895
- */
119896
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
119897
- var _a, _b, _c;
119898
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
119899
- return;
119900
- }
119901
- fn(state, filePath);
119938
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
119939
+ return undefined;
119940
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
119941
+ return true;
119942
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
119902
119943
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
119903
- // Go through exported modules from cache first
119904
119944
  // If exported modules has path, all files referencing file exported from are affected
119905
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
119906
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119907
- });
119908
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
119909
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
119910
- var _a;
119911
- // If the cache had an updated value, skip
119912
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
119913
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
119914
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119945
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
119946
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
119915
119947
  });
119916
119948
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
119917
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
119949
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
119918
119950
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
119919
- fn(state, referencingFilePath);
119920
- } // Dont add to seen since this is not yet done with the export removal
119921
- );
119951
+ handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
119952
+ state, referencingFilePath, cancellationToken, computeHash, host);
119953
+ });
119954
+ return undefined;
119922
119955
  }
119923
119956
  /**
119924
119957
  * This is called after completing operation on the next affected file.
@@ -120294,7 +120327,43 @@ var ts;
120294
120327
  return toAffectedFileEmitResult(state,
120295
120328
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
120296
120329
  // Otherwise just affected file
120297
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120330
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120331
+ getWriteFileUpdatingSignatureCallback(writeFile) :
120332
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120333
+ }
120334
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
120335
+ return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
120336
+ var _a;
120337
+ if (ts.isDeclarationFileName(fileName)) {
120338
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120339
+ var file = sourceFiles[0];
120340
+ var info = state.fileInfos.get(file.resolvedPath);
120341
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
120342
+ if (signature === file.version) {
120343
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
120344
+ if (newSignature !== file.version) { // Update it
120345
+ if (host.storeFilesChangingSignatureDuringEmit)
120346
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120347
+ if (state.exportedModulesMap)
120348
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
120349
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
120350
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
120351
+ }
120352
+ else {
120353
+ info.signature = newSignature;
120354
+ if (state.exportedModulesMap)
120355
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120356
+ }
120357
+ }
120358
+ }
120359
+ }
120360
+ if (writeFile)
120361
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120362
+ else if (host.writeFile)
120363
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120364
+ else
120365
+ state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120366
+ };
120298
120367
  }
120299
120368
  /**
120300
120369
  * Emits the JavaScript and declaration files.
@@ -120351,7 +120420,9 @@ var ts;
120351
120420
  }
120352
120421
  }
120353
120422
  }
120354
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120423
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120424
+ getWriteFileUpdatingSignatureCallback(writeFile) :
120425
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120355
120426
  }
120356
120427
  /**
120357
120428
  * Return the semantic diagnostics for the next affected file or undefined if iteration is complete
@@ -122543,6 +122614,7 @@ var ts;
122543
122614
  createHash: ts.maybeBind(host, host.createHash),
122544
122615
  readDirectory: ts.maybeBind(host, host.readDirectory),
122545
122616
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
122617
+ storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
122546
122618
  };
122547
122619
  function writeFile(fileName, text, writeByteOrderMark, onError) {
122548
122620
  try {
@@ -122602,6 +122674,7 @@ var ts;
122602
122674
  createHash: ts.maybeBind(system, system.createHash),
122603
122675
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
122604
122676
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
122677
+ storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
122605
122678
  };
122606
122679
  }
122607
122680
  ts.createProgramHost = createProgramHost;
@@ -122690,6 +122763,7 @@ var ts;
122690
122763
  var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system);
122691
122764
  host.createHash = ts.maybeBind(system, system.createHash);
122692
122765
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
122766
+ host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
122693
122767
  ts.setGetSourceFileAsHashVersioned(host, system);
122694
122768
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
122695
122769
  return host;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "typescript",
3
3
  "author": "Microsoft Corp.",
4
4
  "homepage": "https://www.typescriptlang.org/",
5
- "version": "4.7.0-dev.20220419",
5
+ "version": "4.7.0-dev.20220422",
6
6
  "license": "Apache-2.0",
7
7
  "description": "TypeScript is a language for application scale JavaScript development",
8
8
  "keywords": [