typescript 4.8.0-dev.20220625 → 4.8.0-dev.20220628

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.20220625";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220628";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -33144,7 +33144,7 @@ var ts;
33144
33144
  }
33145
33145
  return parseElement();
33146
33146
  }
33147
- function currentNode(parsingContext) {
33147
+ function currentNode(parsingContext, pos) {
33148
33148
  // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse.
33149
33149
  //
33150
33150
  // If there is an outstanding parse error that we've encountered, but not attached to
@@ -33157,7 +33157,7 @@ var ts;
33157
33157
  if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
33158
33158
  return undefined;
33159
33159
  }
33160
- var node = syntaxCursor.currentNode(scanner.getStartPos());
33160
+ var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos());
33161
33161
  // Can't reuse a missing node.
33162
33162
  // Can't reuse a node that intersected the change range.
33163
33163
  // Can't reuse a node that contains a parse error. This is necessary so that we
@@ -36779,24 +36779,19 @@ var ts;
36779
36779
  return modifier.kind === 135 /* DeclareKeyword */;
36780
36780
  }
36781
36781
  function parseDeclaration() {
36782
- // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner
36783
- // if we can't reuse the declaration, so that we don't do this work twice?
36784
- //
36785
36782
  // `parseListElement` attempted to get the reused node at this position,
36786
36783
  // but the ambient context flag was not yet set, so the node appeared
36787
36784
  // not reusable in that context.
36788
- var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier);
36789
- if (isAmbient) {
36790
- var node = tryReuseAmbientDeclaration();
36791
- if (node) {
36792
- return node;
36793
- }
36794
- }
36795
36785
  var pos = getNodePos();
36796
36786
  var hasJSDoc = hasPrecedingJSDocComment();
36797
36787
  var decorators = parseDecorators();
36798
36788
  var modifiers = parseModifiers();
36789
+ var isAmbient = ts.some(modifiers, isDeclareModifier);
36799
36790
  if (isAmbient) {
36791
+ var node = tryReuseAmbientDeclaration(pos);
36792
+ if (node) {
36793
+ return node;
36794
+ }
36800
36795
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36801
36796
  var m = _a[_i];
36802
36797
  m.flags |= 16777216 /* Ambient */;
@@ -36807,9 +36802,9 @@ var ts;
36807
36802
  return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
36808
36803
  }
36809
36804
  }
36810
- function tryReuseAmbientDeclaration() {
36805
+ function tryReuseAmbientDeclaration(pos) {
36811
36806
  return doInsideOfContext(16777216 /* Ambient */, function () {
36812
- var node = currentNode(parsingContext);
36807
+ var node = currentNode(parsingContext, pos);
36813
36808
  if (node) {
36814
36809
  return consumeNode(node);
36815
36810
  }
@@ -88245,13 +88240,20 @@ var ts;
88245
88240
  if (!fileToDirective) {
88246
88241
  return undefined;
88247
88242
  }
88243
+ // computed property name should use node as value
88248
88244
  // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause
88249
88245
  // qualified names can only be used as types\namespaces
88250
88246
  // identifiers are treated as values only if they appear in type queries
88251
- var meaning = 788968 /* Type */ | 1920 /* Namespace */;
88252
- if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
88247
+ var meaning;
88248
+ if (node.parent.kind === 162 /* ComputedPropertyName */) {
88253
88249
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88254
88250
  }
88251
+ else {
88252
+ meaning = 788968 /* Type */ | 1920 /* Namespace */;
88253
+ if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
88254
+ meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88255
+ }
88256
+ }
88255
88257
  var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true);
88256
88258
  return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
88257
88259
  }
@@ -111363,7 +111365,6 @@ var ts;
111363
111365
  var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
111364
111366
  var bundleBuildInfo;
111365
111367
  var emitSkipped = false;
111366
- var exportedModulesFromDeclarationEmit;
111367
111368
  // Emit each output file
111368
111369
  enter();
111369
111370
  forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
@@ -111373,7 +111374,6 @@ var ts;
111373
111374
  diagnostics: emitterDiagnostics.getDiagnostics(),
111374
111375
  emittedFiles: emittedFilesList,
111375
111376
  sourceMaps: sourceMapDataList,
111376
- exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
111377
111377
  };
111378
111378
  function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
111379
111379
  var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
@@ -111465,7 +111465,7 @@ var ts;
111465
111465
  substituteNode: transform.substituteNode,
111466
111466
  });
111467
111467
  ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
111468
- printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
111468
+ printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions);
111469
111469
  // Clean up emit nodes on parse tree
111470
111470
  transform.dispose();
111471
111471
  if (bundleBuildInfo)
@@ -111501,7 +111501,7 @@ var ts;
111501
111501
  noEmitHelpers: true,
111502
111502
  module: compilerOptions.module,
111503
111503
  target: compilerOptions.target,
111504
- sourceMap: compilerOptions.sourceMap,
111504
+ sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
111505
111505
  inlineSourceMap: compilerOptions.inlineSourceMap,
111506
111506
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111507
111507
  onlyPrintJsDocStyle: true,
@@ -111521,17 +111521,13 @@ var ts;
111521
111521
  emitSkipped = emitSkipped || declBlocked;
111522
111522
  if (!declBlocked || forceDtsEmit) {
111523
111523
  ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
111524
- printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
111525
- sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
111524
+ printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, {
111525
+ sourceMap: printerOptions.sourceMap,
111526
111526
  sourceRoot: compilerOptions.sourceRoot,
111527
111527
  mapRoot: compilerOptions.mapRoot,
111528
111528
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111529
111529
  // Explicitly do not passthru either `inline` option
111530
111530
  });
111531
- if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) {
111532
- var sourceFile = declarationTransform.transformed[0];
111533
- exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
111534
- }
111535
111531
  }
111536
111532
  declarationTransform.dispose();
111537
111533
  if (bundleBuildInfo)
@@ -111550,7 +111546,8 @@ var ts;
111550
111546
  }
111551
111547
  ts.forEachChild(node, collectLinkedAliases);
111552
111548
  }
111553
- function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
111549
+ function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) {
111550
+ var sourceFileOrBundle = transform.transformed[0];
111554
111551
  var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined;
111555
111552
  var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined;
111556
111553
  var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
@@ -111584,7 +111581,7 @@ var ts;
111584
111581
  var sourceMap = sourceMapGenerator.toString();
111585
111582
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111586
111583
  if (printer.bundleFileInfo)
111587
- printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111584
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111588
111585
  }
111589
111586
  }
111590
111587
  else {
@@ -111592,11 +111589,11 @@ var ts;
111592
111589
  }
111593
111590
  // Write the output file
111594
111591
  var text = writer.getText();
111595
- ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111592
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
111596
111593
  // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo
111597
111594
  // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode
111598
111595
  if (printer.bundleFileInfo)
111599
- printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
111596
+ printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
111600
111597
  // Reset state
111601
111598
  writer.clear();
111602
111599
  }
@@ -111761,25 +111758,25 @@ var ts;
111761
111758
  if (!jsFileText)
111762
111759
  return jsFilePath;
111763
111760
  // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
111764
- if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111761
+ if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111765
111762
  return jsFilePath;
111766
111763
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111767
111764
  // error if no source map or for now if inline sourcemap
111768
111765
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111769
111766
  return sourceMapFilePath || "inline sourcemap decoding";
111770
- if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111767
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111771
111768
  return sourceMapFilePath;
111772
111769
  // read declaration text
111773
111770
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111774
111771
  if (declarationFilePath && !declarationText)
111775
111772
  return declarationFilePath;
111776
- if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111773
+ if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111777
111774
  return declarationFilePath;
111778
111775
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111779
111776
  // error if no source map or for now if inline sourcemap
111780
111777
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111781
111778
  return declarationMapPath || "inline sourcemap decoding";
111782
- if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111779
+ if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111783
111780
  return declarationMapPath;
111784
111781
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111785
111782
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
@@ -111819,7 +111816,7 @@ var ts;
111819
111816
  newBuildInfo.program = buildInfo.program;
111820
111817
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111821
111818
  // Update the output signature
111822
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
111819
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
111823
111820
  newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111824
111821
  }
111825
111822
  // Update sourceFileInfo
@@ -120704,8 +120701,8 @@ var ts;
120704
120701
  (function (ts) {
120705
120702
  function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
120706
120703
  var outputFiles = [];
120707
- var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
120708
- return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
120704
+ var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics;
120705
+ return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics };
120709
120706
  function writeFile(fileName, text, writeByteOrderMark) {
120710
120707
  outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
120711
120708
  }
@@ -120929,23 +120926,23 @@ var ts;
120929
120926
  /**
120930
120927
  * Gets the files affected by the path from the program
120931
120928
  */
120932
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120929
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120933
120930
  var _a, _b;
120934
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120931
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
120935
120932
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120936
120933
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120937
120934
  return result;
120938
120935
  }
120939
120936
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120940
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120937
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120941
120938
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120942
120939
  if (!sourceFile) {
120943
120940
  return ts.emptyArray;
120944
120941
  }
120945
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120942
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
120946
120943
  return [sourceFile];
120947
120944
  }
120948
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120945
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
120949
120946
  }
120950
120947
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120951
120948
  function updateSignatureOfFile(state, signature, path) {
@@ -120956,7 +120953,7 @@ var ts;
120956
120953
  /**
120957
120954
  * Returns if the shape of the signature has changed since last emit
120958
120955
  */
120959
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120956
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
120960
120957
  var _a;
120961
120958
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120962
120959
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
@@ -120966,18 +120963,16 @@ var ts;
120966
120963
  var prevSignature = info.signature;
120967
120964
  var latestSignature;
120968
120965
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
120969
- var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile,
120970
- /*emitOnlyDtsFiles*/ true, cancellationToken,
120971
- /*customTransformers*/ undefined,
120972
- /*forceDtsEmit*/ true);
120973
- var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120974
- if (firstDts_1) {
120975
- ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
120976
- latestSignature = computeSignature(firstDts_1.text, computeHash);
120966
+ programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
120967
+ ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
120968
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
120977
120969
  if (latestSignature !== prevSignature) {
120978
- updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120970
+ updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
120979
120971
  }
120980
- }
120972
+ }, cancellationToken,
120973
+ /*emitOnlyDtsFiles*/ true,
120974
+ /*customTransformers*/ undefined,
120975
+ /*forceDtsEmit*/ true);
120981
120976
  }
120982
120977
  // Default is to use file version as signature
120983
120978
  if (latestSignature === undefined) {
@@ -121000,10 +120995,6 @@ var ts;
121000
120995
  return latestSignature !== prevSignature;
121001
120996
  }
121002
120997
  BuilderState.updateShapeSignature = updateShapeSignature;
121003
- function computeSignature(text, computeHash) {
121004
- return (computeHash || ts.generateDjb2Hash)(text);
121005
- }
121006
- BuilderState.computeSignature = computeSignature;
121007
120998
  /**
121008
120999
  * Coverts the declaration emit result into exported modules map
121009
121000
  */
@@ -121153,7 +121144,7 @@ var ts;
121153
121144
  /**
121154
121145
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
121155
121146
  */
121156
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
121147
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
121157
121148
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
121158
121149
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
121159
121150
  }
@@ -121173,7 +121164,7 @@ var ts;
121173
121164
  if (!seenFileNamesMap.has(currentPath)) {
121174
121165
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
121175
121166
  seenFileNamesMap.set(currentPath, currentSourceFile);
121176
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
121167
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
121177
121168
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
121178
121169
  }
121179
121170
  }
@@ -121367,7 +121358,7 @@ var ts;
121367
121358
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
121368
121359
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
121369
121360
  */
121370
- function getNextAffectedFile(state, cancellationToken, computeHash, host) {
121361
+ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
121371
121362
  var _a, _b;
121372
121363
  while (true) {
121373
121364
  var affectedFiles = state.affectedFiles;
@@ -121379,7 +121370,7 @@ var ts;
121379
121370
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
121380
121371
  // Set the next affected file as seen and remove the cached semantic diagnostics
121381
121372
  state.affectedFilesIndex = affectedFilesIndex;
121382
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121373
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121383
121374
  return affectedFile;
121384
121375
  }
121385
121376
  affectedFilesIndex++;
@@ -121407,7 +121398,7 @@ var ts;
121407
121398
  return program;
121408
121399
  }
121409
121400
  // Get next batch of affected files
121410
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
121401
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
121411
121402
  state.currentChangedFilePath = nextKey.value;
121412
121403
  state.affectedFilesIndex = 0;
121413
121404
  if (!state.seenAffectedFiles)
@@ -121458,7 +121449,7 @@ var ts;
121458
121449
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
121459
121450
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
121460
121451
  */
121461
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121452
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121462
121453
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
121463
121454
  // If affected files is everything except default library, then nothing more to do
121464
121455
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -121466,18 +121457,18 @@ var ts;
121466
121457
  // When a change affects the global scope, all files are considered to be affected without updating their signature
121467
121458
  // That means when affected file is handled, its signature can be out of date
121468
121459
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
121469
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
121460
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
121470
121461
  return;
121471
121462
  }
121472
121463
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
121473
121464
  return;
121474
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121465
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121475
121466
  }
121476
121467
  /**
121477
121468
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
121478
121469
  * Also we need to make sure signature is updated for these files
121479
121470
  */
121480
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
121471
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
121481
121472
  removeSemanticDiagnosticsOf(state, path);
121482
121473
  if (!state.changedFilesSet.has(path)) {
121483
121474
  var program = ts.Debug.checkDefined(state.program);
@@ -121488,7 +121479,7 @@ var ts;
121488
121479
  // This ensures that we dont later during incremental builds considering wrong signature.
121489
121480
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
121490
121481
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
121491
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
121482
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
121492
121483
  // If not dts emit, nothing more to do
121493
121484
  if (ts.getEmitDeclarations(state.compilerOptions)) {
121494
121485
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -121513,20 +121504,20 @@ var ts;
121513
121504
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
121514
121505
  return newSignature !== oldSignature;
121515
121506
  }
121516
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
121507
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
121517
121508
  var _a;
121518
121509
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
121519
121510
  return false;
121520
121511
  // Every file needs to be handled
121521
121512
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
121522
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
121513
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
121523
121514
  removeDiagnosticsOfLibraryFiles(state);
121524
121515
  return true;
121525
121516
  }
121526
121517
  /**
121527
121518
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
121528
121519
  */
121529
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121520
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121530
121521
  var _a;
121531
121522
  // If there was change in signature (dts output) for the changed file,
121532
121523
  // then only we need to handle pending file emit
@@ -121544,9 +121535,9 @@ var ts;
121544
121535
  var currentPath = queue.pop();
121545
121536
  if (!seenFileNamesMap.has(currentPath)) {
121546
121537
  seenFileNamesMap.set(currentPath, true);
121547
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
121538
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
121548
121539
  return;
121549
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
121540
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
121550
121541
  if (isChangedSignature(state, currentPath)) {
121551
121542
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
121552
121543
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -121558,11 +121549,11 @@ var ts;
121558
121549
  // Go through exported modules from cache first
121559
121550
  // If exported modules has path, all files referencing file exported from are affected
121560
121551
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121561
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
121552
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
121562
121553
  return true;
121563
121554
  var references = state.referencedMap.getKeys(exportedFromPath);
121564
121555
  return references && ts.forEachKey(references, function (filePath) {
121565
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121556
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121566
121557
  });
121567
121558
  });
121568
121559
  }
@@ -121570,22 +121561,22 @@ var ts;
121570
121561
  * handle dts and semantic diagnostics on file and iterate on anything that exports this file
121571
121562
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
121572
121563
  */
121573
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
121564
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121574
121565
  var _a, _b;
121575
121566
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
121576
121567
  return undefined;
121577
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
121568
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
121578
121569
  return true;
121579
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
121570
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
121580
121571
  // If exported modules has path, all files referencing file exported from are affected
121581
121572
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121582
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121573
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121583
121574
  });
121584
121575
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
121585
121576
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
121586
121577
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
121587
121578
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
121588
- state, referencingFilePath, cancellationToken, computeHash, host);
121579
+ state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
121589
121580
  });
121590
121581
  return undefined;
121591
121582
  }
@@ -121904,8 +121895,39 @@ var ts;
121904
121895
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121905
121896
  }
121906
121897
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121907
- function computeSignature(text, data, computeHash) {
121908
- return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121898
+ function getTextHandlingSourceMapForSignature(text, data) {
121899
+ return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
121900
+ }
121901
+ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
121902
+ var _a;
121903
+ text = getTextHandlingSourceMapForSignature(text, data);
121904
+ var sourceFileDirectory;
121905
+ if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
121906
+ text += data.diagnostics.map(function (diagnostic) {
121907
+ return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
121908
+ }).join("\n");
121909
+ }
121910
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
121911
+ function flattenDiagnosticMessageText(diagnostic) {
121912
+ return ts.isString(diagnostic) ?
121913
+ diagnostic :
121914
+ diagnostic === undefined ?
121915
+ "" :
121916
+ !diagnostic.next ?
121917
+ diagnostic.messageText :
121918
+ diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n");
121919
+ }
121920
+ function locationInfo(diagnostic) {
121921
+ if (diagnostic.file.resolvedPath === sourceFile.resolvedPath)
121922
+ return "(" + diagnostic.start + "," + diagnostic.length + ")";
121923
+ if (sourceFileDirectory === undefined)
121924
+ sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
121925
+ return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)) + "(" + diagnostic.start + "," + diagnostic.length + ")";
121926
+ }
121927
+ }
121928
+ ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
121929
+ function computeSignature(text, computeHash, data) {
121930
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
121909
121931
  }
121910
121932
  ts.computeSignature = computeSignature;
121911
121933
  function createBuilderProgram(kind, _a) {
@@ -121966,7 +121988,7 @@ var ts;
121966
121988
  * in that order would be used to write the files
121967
121989
  */
121968
121990
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
121969
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
121991
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
121970
121992
  var emitKind = 1 /* Full */;
121971
121993
  var isPendingEmitFile = false;
121972
121994
  if (!affected) {
@@ -122003,32 +122025,35 @@ var ts;
122003
122025
  }
122004
122026
  function getWriteFileCallback(writeFile, customTransformers) {
122005
122027
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
122006
- var _a, _b, _c;
122028
+ var _a, _b, _c, _d, _e, _f, _g;
122007
122029
  if (ts.isDeclarationFileName(fileName)) {
122008
122030
  if (!ts.outFile(state.compilerOptions)) {
122009
122031
  ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
122010
- var newSignature = void 0;
122032
+ var emitSignature = void 0;
122011
122033
  if (!customTransformers) {
122012
122034
  var file = sourceFiles[0];
122013
122035
  var info = state.fileInfos.get(file.resolvedPath);
122014
122036
  if (info.signature === file.version) {
122015
- newSignature = computeSignature(text, data, computeHash);
122016
- if (newSignature !== file.version) { // Update it
122037
+ var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
122038
+ // With d.ts diagnostics they are also part of the signature so emitSignature will be different from it since its just hash of d.ts
122039
+ if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
122040
+ emitSignature = signature;
122041
+ if (signature !== file.version) { // Update it
122017
122042
  if (host.storeFilesChangingSignatureDuringEmit)
122018
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
122043
+ ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
122019
122044
  if (state.exportedModulesMap)
122020
122045
  ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
122021
122046
  if (state.affectedFiles) {
122022
122047
  // Keep old signature so we know what to undo if cancellation happens
122023
- var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
122048
+ var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath);
122024
122049
  if (existing === undefined)
122025
- (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
122026
- info.signature = newSignature;
122050
+ ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
122051
+ info.signature = signature;
122027
122052
  }
122028
122053
  else {
122029
122054
  // These are directly commited
122030
- info.signature = newSignature;
122031
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
122055
+ info.signature = signature;
122056
+ (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear();
122032
122057
  }
122033
122058
  }
122034
122059
  }
@@ -122038,16 +122063,16 @@ var ts;
122038
122063
  // and would need their d.ts change time in --build mode
122039
122064
  if (state.compilerOptions.composite) {
122040
122065
  var filePath = sourceFiles[0].resolvedPath;
122041
- var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
122042
- newSignature || (newSignature = computeSignature(text, data, computeHash));
122043
- if (newSignature !== oldSignature) {
122044
- (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
122066
+ var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
122067
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
122068
+ if (emitSignature !== oldSignature) {
122069
+ ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
122045
122070
  state.hasChangedEmitSignature = true;
122046
122071
  }
122047
122072
  }
122048
122073
  }
122049
122074
  else if (state.compilerOptions.composite) {
122050
- var newSignature = computeSignature(text, data, computeHash);
122075
+ var newSignature = computeSignature(text, computeHash, data);
122051
122076
  if (newSignature !== state.outSignature) {
122052
122077
  state.outSignature = newSignature;
122053
122078
  state.hasChangedEmitSignature = true;
@@ -122127,7 +122152,7 @@ var ts;
122127
122152
  */
122128
122153
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
122129
122154
  while (true) {
122130
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
122155
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
122131
122156
  if (!affected) {
122132
122157
  // Done
122133
122158
  return undefined;
@@ -128992,12 +129017,18 @@ var ts;
128992
129017
  // flag causes us to return the first node whose end position matches the position and which produces and acceptable token
128993
129018
  // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the
128994
129019
  // position and whose end is greater than the position.
129020
+ // There are more sophisticated end tests later, but this one is very fast
129021
+ // and allows us to skip a bunch of work
129022
+ var end = children[middle].getEnd();
129023
+ if (end < position) {
129024
+ return -1 /* LessThan */;
129025
+ }
128995
129026
  var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true);
128996
129027
  if (start > position) {
128997
129028
  return 1 /* GreaterThan */;
128998
129029
  }
128999
129030
  // first element whose start position is before the input and whose end position is after or equal to the input
129000
- if (nodeContainsPosition(children[middle])) {
129031
+ if (nodeContainsPosition(children[middle], start, end)) {
129001
129032
  if (children[middle - 1]) {
129002
129033
  // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position
129003
129034
  if (nodeContainsPosition(children[middle - 1])) {
@@ -129029,13 +129060,16 @@ var ts;
129029
129060
  case "continue-outer": continue outer;
129030
129061
  }
129031
129062
  }
129032
- function nodeContainsPosition(node) {
129033
- var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true);
129063
+ function nodeContainsPosition(node, start, end) {
129064
+ end !== null && end !== void 0 ? end : (end = node.getEnd());
129065
+ if (end < position) {
129066
+ return false;
129067
+ }
129068
+ start !== null && start !== void 0 ? start : (start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true));
129034
129069
  if (start > position) {
129035
129070
  // If this child begins after position, then all subsequent children will as well.
129036
129071
  return false;
129037
129072
  }
129038
- var end = node.getEnd();
129039
129073
  if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) {
129040
129074
  return true;
129041
129075
  }