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.
package/lib/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-dev.20220625";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220628";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -32959,7 +32959,7 @@ var ts;
32959
32959
  }
32960
32960
  return parseElement();
32961
32961
  }
32962
- function currentNode(parsingContext) {
32962
+ function currentNode(parsingContext, pos) {
32963
32963
  // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse.
32964
32964
  //
32965
32965
  // If there is an outstanding parse error that we've encountered, but not attached to
@@ -32972,7 +32972,7 @@ var ts;
32972
32972
  if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
32973
32973
  return undefined;
32974
32974
  }
32975
- var node = syntaxCursor.currentNode(scanner.getStartPos());
32975
+ var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos());
32976
32976
  // Can't reuse a missing node.
32977
32977
  // Can't reuse a node that intersected the change range.
32978
32978
  // Can't reuse a node that contains a parse error. This is necessary so that we
@@ -36594,24 +36594,19 @@ var ts;
36594
36594
  return modifier.kind === 135 /* DeclareKeyword */;
36595
36595
  }
36596
36596
  function parseDeclaration() {
36597
- // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner
36598
- // if we can't reuse the declaration, so that we don't do this work twice?
36599
- //
36600
36597
  // `parseListElement` attempted to get the reused node at this position,
36601
36598
  // but the ambient context flag was not yet set, so the node appeared
36602
36599
  // not reusable in that context.
36603
- var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier);
36604
- if (isAmbient) {
36605
- var node = tryReuseAmbientDeclaration();
36606
- if (node) {
36607
- return node;
36608
- }
36609
- }
36610
36600
  var pos = getNodePos();
36611
36601
  var hasJSDoc = hasPrecedingJSDocComment();
36612
36602
  var decorators = parseDecorators();
36613
36603
  var modifiers = parseModifiers();
36604
+ var isAmbient = ts.some(modifiers, isDeclareModifier);
36614
36605
  if (isAmbient) {
36606
+ var node = tryReuseAmbientDeclaration(pos);
36607
+ if (node) {
36608
+ return node;
36609
+ }
36615
36610
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36616
36611
  var m = _a[_i];
36617
36612
  m.flags |= 16777216 /* Ambient */;
@@ -36622,9 +36617,9 @@ var ts;
36622
36617
  return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
36623
36618
  }
36624
36619
  }
36625
- function tryReuseAmbientDeclaration() {
36620
+ function tryReuseAmbientDeclaration(pos) {
36626
36621
  return doInsideOfContext(16777216 /* Ambient */, function () {
36627
- var node = currentNode(parsingContext);
36622
+ var node = currentNode(parsingContext, pos);
36628
36623
  if (node) {
36629
36624
  return consumeNode(node);
36630
36625
  }
@@ -88060,13 +88055,20 @@ var ts;
88060
88055
  if (!fileToDirective) {
88061
88056
  return undefined;
88062
88057
  }
88058
+ // computed property name should use node as value
88063
88059
  // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause
88064
88060
  // qualified names can only be used as types\namespaces
88065
88061
  // identifiers are treated as values only if they appear in type queries
88066
- var meaning = 788968 /* Type */ | 1920 /* Namespace */;
88067
- if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
88062
+ var meaning;
88063
+ if (node.parent.kind === 162 /* ComputedPropertyName */) {
88068
88064
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88069
88065
  }
88066
+ else {
88067
+ meaning = 788968 /* Type */ | 1920 /* Namespace */;
88068
+ if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
88069
+ meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88070
+ }
88071
+ }
88070
88072
  var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true);
88071
88073
  return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
88072
88074
  }
@@ -111178,7 +111180,6 @@ var ts;
111178
111180
  var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
111179
111181
  var bundleBuildInfo;
111180
111182
  var emitSkipped = false;
111181
- var exportedModulesFromDeclarationEmit;
111182
111183
  // Emit each output file
111183
111184
  enter();
111184
111185
  forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
@@ -111188,7 +111189,6 @@ var ts;
111188
111189
  diagnostics: emitterDiagnostics.getDiagnostics(),
111189
111190
  emittedFiles: emittedFilesList,
111190
111191
  sourceMaps: sourceMapDataList,
111191
- exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
111192
111192
  };
111193
111193
  function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
111194
111194
  var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
@@ -111280,7 +111280,7 @@ var ts;
111280
111280
  substituteNode: transform.substituteNode,
111281
111281
  });
111282
111282
  ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
111283
- printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
111283
+ printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions);
111284
111284
  // Clean up emit nodes on parse tree
111285
111285
  transform.dispose();
111286
111286
  if (bundleBuildInfo)
@@ -111316,7 +111316,7 @@ var ts;
111316
111316
  noEmitHelpers: true,
111317
111317
  module: compilerOptions.module,
111318
111318
  target: compilerOptions.target,
111319
- sourceMap: compilerOptions.sourceMap,
111319
+ sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
111320
111320
  inlineSourceMap: compilerOptions.inlineSourceMap,
111321
111321
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111322
111322
  onlyPrintJsDocStyle: true,
@@ -111336,17 +111336,13 @@ var ts;
111336
111336
  emitSkipped = emitSkipped || declBlocked;
111337
111337
  if (!declBlocked || forceDtsEmit) {
111338
111338
  ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
111339
- printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
111340
- sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
111339
+ printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, {
111340
+ sourceMap: printerOptions.sourceMap,
111341
111341
  sourceRoot: compilerOptions.sourceRoot,
111342
111342
  mapRoot: compilerOptions.mapRoot,
111343
111343
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111344
111344
  // Explicitly do not passthru either `inline` option
111345
111345
  });
111346
- if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) {
111347
- var sourceFile = declarationTransform.transformed[0];
111348
- exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
111349
- }
111350
111346
  }
111351
111347
  declarationTransform.dispose();
111352
111348
  if (bundleBuildInfo)
@@ -111365,7 +111361,8 @@ var ts;
111365
111361
  }
111366
111362
  ts.forEachChild(node, collectLinkedAliases);
111367
111363
  }
111368
- function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
111364
+ function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) {
111365
+ var sourceFileOrBundle = transform.transformed[0];
111369
111366
  var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined;
111370
111367
  var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined;
111371
111368
  var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
@@ -111399,7 +111396,7 @@ var ts;
111399
111396
  var sourceMap = sourceMapGenerator.toString();
111400
111397
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111401
111398
  if (printer.bundleFileInfo)
111402
- printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111399
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111403
111400
  }
111404
111401
  }
111405
111402
  else {
@@ -111407,11 +111404,11 @@ var ts;
111407
111404
  }
111408
111405
  // Write the output file
111409
111406
  var text = writer.getText();
111410
- ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111407
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
111411
111408
  // 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
111412
111409
  // 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
111413
111410
  if (printer.bundleFileInfo)
111414
- printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
111411
+ printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
111415
111412
  // Reset state
111416
111413
  writer.clear();
111417
111414
  }
@@ -111576,25 +111573,25 @@ var ts;
111576
111573
  if (!jsFileText)
111577
111574
  return jsFilePath;
111578
111575
  // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
111579
- if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111576
+ if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111580
111577
  return jsFilePath;
111581
111578
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111582
111579
  // error if no source map or for now if inline sourcemap
111583
111580
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111584
111581
  return sourceMapFilePath || "inline sourcemap decoding";
111585
- if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111582
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111586
111583
  return sourceMapFilePath;
111587
111584
  // read declaration text
111588
111585
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111589
111586
  if (declarationFilePath && !declarationText)
111590
111587
  return declarationFilePath;
111591
- if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111588
+ if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111592
111589
  return declarationFilePath;
111593
111590
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111594
111591
  // error if no source map or for now if inline sourcemap
111595
111592
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111596
111593
  return declarationMapPath || "inline sourcemap decoding";
111597
- if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111594
+ if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111598
111595
  return declarationMapPath;
111599
111596
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111600
111597
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
@@ -111634,7 +111631,7 @@ var ts;
111634
111631
  newBuildInfo.program = buildInfo.program;
111635
111632
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111636
111633
  // Update the output signature
111637
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
111634
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
111638
111635
  newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111639
111636
  }
111640
111637
  // Update sourceFileInfo
@@ -120519,8 +120516,8 @@ var ts;
120519
120516
  (function (ts) {
120520
120517
  function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
120521
120518
  var outputFiles = [];
120522
- var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
120523
- return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
120519
+ var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics;
120520
+ return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics };
120524
120521
  function writeFile(fileName, text, writeByteOrderMark) {
120525
120522
  outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
120526
120523
  }
@@ -120744,23 +120741,23 @@ var ts;
120744
120741
  /**
120745
120742
  * Gets the files affected by the path from the program
120746
120743
  */
120747
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120744
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120748
120745
  var _a, _b;
120749
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120746
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
120750
120747
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120751
120748
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120752
120749
  return result;
120753
120750
  }
120754
120751
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120755
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120752
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120756
120753
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120757
120754
  if (!sourceFile) {
120758
120755
  return ts.emptyArray;
120759
120756
  }
120760
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120757
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
120761
120758
  return [sourceFile];
120762
120759
  }
120763
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120760
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
120764
120761
  }
120765
120762
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120766
120763
  function updateSignatureOfFile(state, signature, path) {
@@ -120771,7 +120768,7 @@ var ts;
120771
120768
  /**
120772
120769
  * Returns if the shape of the signature has changed since last emit
120773
120770
  */
120774
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120771
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
120775
120772
  var _a;
120776
120773
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120777
120774
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
@@ -120781,18 +120778,16 @@ var ts;
120781
120778
  var prevSignature = info.signature;
120782
120779
  var latestSignature;
120783
120780
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
120784
- var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile,
120785
- /*emitOnlyDtsFiles*/ true, cancellationToken,
120786
- /*customTransformers*/ undefined,
120787
- /*forceDtsEmit*/ true);
120788
- var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120789
- if (firstDts_1) {
120790
- 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; })); });
120791
- latestSignature = computeSignature(firstDts_1.text, computeHash);
120781
+ programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
120782
+ ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
120783
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
120792
120784
  if (latestSignature !== prevSignature) {
120793
- updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120785
+ updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
120794
120786
  }
120795
- }
120787
+ }, cancellationToken,
120788
+ /*emitOnlyDtsFiles*/ true,
120789
+ /*customTransformers*/ undefined,
120790
+ /*forceDtsEmit*/ true);
120796
120791
  }
120797
120792
  // Default is to use file version as signature
120798
120793
  if (latestSignature === undefined) {
@@ -120815,10 +120810,6 @@ var ts;
120815
120810
  return latestSignature !== prevSignature;
120816
120811
  }
120817
120812
  BuilderState.updateShapeSignature = updateShapeSignature;
120818
- function computeSignature(text, computeHash) {
120819
- return (computeHash || ts.generateDjb2Hash)(text);
120820
- }
120821
- BuilderState.computeSignature = computeSignature;
120822
120813
  /**
120823
120814
  * Coverts the declaration emit result into exported modules map
120824
120815
  */
@@ -120968,7 +120959,7 @@ var ts;
120968
120959
  /**
120969
120960
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120970
120961
  */
120971
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120962
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
120972
120963
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120973
120964
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120974
120965
  }
@@ -120988,7 +120979,7 @@ var ts;
120988
120979
  if (!seenFileNamesMap.has(currentPath)) {
120989
120980
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120990
120981
  seenFileNamesMap.set(currentPath, currentSourceFile);
120991
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
120982
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
120992
120983
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120993
120984
  }
120994
120985
  }
@@ -121182,7 +121173,7 @@ var ts;
121182
121173
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
121183
121174
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
121184
121175
  */
121185
- function getNextAffectedFile(state, cancellationToken, computeHash, host) {
121176
+ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
121186
121177
  var _a, _b;
121187
121178
  while (true) {
121188
121179
  var affectedFiles = state.affectedFiles;
@@ -121194,7 +121185,7 @@ var ts;
121194
121185
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
121195
121186
  // Set the next affected file as seen and remove the cached semantic diagnostics
121196
121187
  state.affectedFilesIndex = affectedFilesIndex;
121197
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121188
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121198
121189
  return affectedFile;
121199
121190
  }
121200
121191
  affectedFilesIndex++;
@@ -121222,7 +121213,7 @@ var ts;
121222
121213
  return program;
121223
121214
  }
121224
121215
  // Get next batch of affected files
121225
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
121216
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
121226
121217
  state.currentChangedFilePath = nextKey.value;
121227
121218
  state.affectedFilesIndex = 0;
121228
121219
  if (!state.seenAffectedFiles)
@@ -121273,7 +121264,7 @@ var ts;
121273
121264
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
121274
121265
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
121275
121266
  */
121276
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121267
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121277
121268
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
121278
121269
  // If affected files is everything except default library, then nothing more to do
121279
121270
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -121281,18 +121272,18 @@ var ts;
121281
121272
  // When a change affects the global scope, all files are considered to be affected without updating their signature
121282
121273
  // That means when affected file is handled, its signature can be out of date
121283
121274
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
121284
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
121275
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
121285
121276
  return;
121286
121277
  }
121287
121278
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
121288
121279
  return;
121289
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121280
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121290
121281
  }
121291
121282
  /**
121292
121283
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
121293
121284
  * Also we need to make sure signature is updated for these files
121294
121285
  */
121295
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
121286
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
121296
121287
  removeSemanticDiagnosticsOf(state, path);
121297
121288
  if (!state.changedFilesSet.has(path)) {
121298
121289
  var program = ts.Debug.checkDefined(state.program);
@@ -121303,7 +121294,7 @@ var ts;
121303
121294
  // This ensures that we dont later during incremental builds considering wrong signature.
121304
121295
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
121305
121296
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
121306
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
121297
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
121307
121298
  // If not dts emit, nothing more to do
121308
121299
  if (ts.getEmitDeclarations(state.compilerOptions)) {
121309
121300
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -121328,20 +121319,20 @@ var ts;
121328
121319
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
121329
121320
  return newSignature !== oldSignature;
121330
121321
  }
121331
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
121322
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
121332
121323
  var _a;
121333
121324
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
121334
121325
  return false;
121335
121326
  // Every file needs to be handled
121336
121327
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
121337
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
121328
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
121338
121329
  removeDiagnosticsOfLibraryFiles(state);
121339
121330
  return true;
121340
121331
  }
121341
121332
  /**
121342
121333
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
121343
121334
  */
121344
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121335
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121345
121336
  var _a;
121346
121337
  // If there was change in signature (dts output) for the changed file,
121347
121338
  // then only we need to handle pending file emit
@@ -121359,9 +121350,9 @@ var ts;
121359
121350
  var currentPath = queue.pop();
121360
121351
  if (!seenFileNamesMap.has(currentPath)) {
121361
121352
  seenFileNamesMap.set(currentPath, true);
121362
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
121353
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
121363
121354
  return;
121364
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
121355
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
121365
121356
  if (isChangedSignature(state, currentPath)) {
121366
121357
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
121367
121358
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -121373,11 +121364,11 @@ var ts;
121373
121364
  // Go through exported modules from cache first
121374
121365
  // If exported modules has path, all files referencing file exported from are affected
121375
121366
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121376
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
121367
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
121377
121368
  return true;
121378
121369
  var references = state.referencedMap.getKeys(exportedFromPath);
121379
121370
  return references && ts.forEachKey(references, function (filePath) {
121380
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121371
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121381
121372
  });
121382
121373
  });
121383
121374
  }
@@ -121385,22 +121376,22 @@ var ts;
121385
121376
  * handle dts and semantic diagnostics on file and iterate on anything that exports this file
121386
121377
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
121387
121378
  */
121388
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
121379
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121389
121380
  var _a, _b;
121390
121381
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
121391
121382
  return undefined;
121392
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
121383
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
121393
121384
  return true;
121394
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
121385
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
121395
121386
  // If exported modules has path, all files referencing file exported from are affected
121396
121387
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121397
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121388
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121398
121389
  });
121399
121390
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
121400
121391
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
121401
121392
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
121402
121393
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
121403
- state, referencingFilePath, cancellationToken, computeHash, host);
121394
+ state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
121404
121395
  });
121405
121396
  return undefined;
121406
121397
  }
@@ -121719,8 +121710,39 @@ var ts;
121719
121710
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121720
121711
  }
121721
121712
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121722
- function computeSignature(text, data, computeHash) {
121723
- return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121713
+ function getTextHandlingSourceMapForSignature(text, data) {
121714
+ return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
121715
+ }
121716
+ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
121717
+ var _a;
121718
+ text = getTextHandlingSourceMapForSignature(text, data);
121719
+ var sourceFileDirectory;
121720
+ if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
121721
+ text += data.diagnostics.map(function (diagnostic) {
121722
+ return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
121723
+ }).join("\n");
121724
+ }
121725
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
121726
+ function flattenDiagnosticMessageText(diagnostic) {
121727
+ return ts.isString(diagnostic) ?
121728
+ diagnostic :
121729
+ diagnostic === undefined ?
121730
+ "" :
121731
+ !diagnostic.next ?
121732
+ diagnostic.messageText :
121733
+ diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n");
121734
+ }
121735
+ function locationInfo(diagnostic) {
121736
+ if (diagnostic.file.resolvedPath === sourceFile.resolvedPath)
121737
+ return "(" + diagnostic.start + "," + diagnostic.length + ")";
121738
+ if (sourceFileDirectory === undefined)
121739
+ sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
121740
+ return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)) + "(" + diagnostic.start + "," + diagnostic.length + ")";
121741
+ }
121742
+ }
121743
+ ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
121744
+ function computeSignature(text, computeHash, data) {
121745
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
121724
121746
  }
121725
121747
  ts.computeSignature = computeSignature;
121726
121748
  function createBuilderProgram(kind, _a) {
@@ -121781,7 +121803,7 @@ var ts;
121781
121803
  * in that order would be used to write the files
121782
121804
  */
121783
121805
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
121784
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
121806
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
121785
121807
  var emitKind = 1 /* Full */;
121786
121808
  var isPendingEmitFile = false;
121787
121809
  if (!affected) {
@@ -121818,32 +121840,35 @@ var ts;
121818
121840
  }
121819
121841
  function getWriteFileCallback(writeFile, customTransformers) {
121820
121842
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
121821
- var _a, _b, _c;
121843
+ var _a, _b, _c, _d, _e, _f, _g;
121822
121844
  if (ts.isDeclarationFileName(fileName)) {
121823
121845
  if (!ts.outFile(state.compilerOptions)) {
121824
121846
  ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121825
- var newSignature = void 0;
121847
+ var emitSignature = void 0;
121826
121848
  if (!customTransformers) {
121827
121849
  var file = sourceFiles[0];
121828
121850
  var info = state.fileInfos.get(file.resolvedPath);
121829
121851
  if (info.signature === file.version) {
121830
- newSignature = computeSignature(text, data, computeHash);
121831
- if (newSignature !== file.version) { // Update it
121852
+ var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
121853
+ // 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
121854
+ if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
121855
+ emitSignature = signature;
121856
+ if (signature !== file.version) { // Update it
121832
121857
  if (host.storeFilesChangingSignatureDuringEmit)
121833
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121858
+ ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121834
121859
  if (state.exportedModulesMap)
121835
121860
  ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
121836
121861
  if (state.affectedFiles) {
121837
121862
  // Keep old signature so we know what to undo if cancellation happens
121838
- var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
121863
+ var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath);
121839
121864
  if (existing === undefined)
121840
- (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121841
- info.signature = newSignature;
121865
+ ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121866
+ info.signature = signature;
121842
121867
  }
121843
121868
  else {
121844
121869
  // These are directly commited
121845
- info.signature = newSignature;
121846
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121870
+ info.signature = signature;
121871
+ (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear();
121847
121872
  }
121848
121873
  }
121849
121874
  }
@@ -121853,16 +121878,16 @@ var ts;
121853
121878
  // and would need their d.ts change time in --build mode
121854
121879
  if (state.compilerOptions.composite) {
121855
121880
  var filePath = sourceFiles[0].resolvedPath;
121856
- var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
121857
- newSignature || (newSignature = computeSignature(text, data, computeHash));
121858
- if (newSignature !== oldSignature) {
121859
- (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
121881
+ var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
121882
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
121883
+ if (emitSignature !== oldSignature) {
121884
+ ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
121860
121885
  state.hasChangedEmitSignature = true;
121861
121886
  }
121862
121887
  }
121863
121888
  }
121864
121889
  else if (state.compilerOptions.composite) {
121865
- var newSignature = computeSignature(text, data, computeHash);
121890
+ var newSignature = computeSignature(text, computeHash, data);
121866
121891
  if (newSignature !== state.outSignature) {
121867
121892
  state.outSignature = newSignature;
121868
121893
  state.hasChangedEmitSignature = true;
@@ -121942,7 +121967,7 @@ var ts;
121942
121967
  */
121943
121968
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
121944
121969
  while (true) {
121945
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
121970
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
121946
121971
  if (!affected) {
121947
121972
  // Done
121948
121973
  return undefined;
@@ -128388,12 +128413,18 @@ var ts;
128388
128413
  // flag causes us to return the first node whose end position matches the position and which produces and acceptable token
128389
128414
  // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the
128390
128415
  // position and whose end is greater than the position.
128416
+ // There are more sophisticated end tests later, but this one is very fast
128417
+ // and allows us to skip a bunch of work
128418
+ var end = children[middle].getEnd();
128419
+ if (end < position) {
128420
+ return -1 /* LessThan */;
128421
+ }
128391
128422
  var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true);
128392
128423
  if (start > position) {
128393
128424
  return 1 /* GreaterThan */;
128394
128425
  }
128395
128426
  // first element whose start position is before the input and whose end position is after or equal to the input
128396
- if (nodeContainsPosition(children[middle])) {
128427
+ if (nodeContainsPosition(children[middle], start, end)) {
128397
128428
  if (children[middle - 1]) {
128398
128429
  // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position
128399
128430
  if (nodeContainsPosition(children[middle - 1])) {
@@ -128425,13 +128456,16 @@ var ts;
128425
128456
  case "continue-outer": continue outer;
128426
128457
  }
128427
128458
  }
128428
- function nodeContainsPosition(node) {
128429
- var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true);
128459
+ function nodeContainsPosition(node, start, end) {
128460
+ end !== null && end !== void 0 ? end : (end = node.getEnd());
128461
+ if (end < position) {
128462
+ return false;
128463
+ }
128464
+ start !== null && start !== void 0 ? start : (start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true));
128430
128465
  if (start > position) {
128431
128466
  // If this child begins after position, then all subsequent children will as well.
128432
128467
  return false;
128433
128468
  }
128434
- var end = node.getEnd();
128435
128469
  if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) {
128436
128470
  return true;
128437
128471
  }
@@ -171067,7 +171101,7 @@ var ts;
171067
171101
  }
171068
171102
  server.updateProjectIfDirty(this);
171069
171103
  this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState, /*disableUseFileVersionAsSignature*/ true);
171070
- return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, ts.maybeBind(this.projectService.host, this.projectService.host.createHash)), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; });
171104
+ return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, ts.maybeBind(this.projectService.host, this.projectService.host.createHash), this.getCanonicalFileName), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; });
171071
171105
  };
171072
171106
  /**
171073
171107
  * Returns true if emit was conducted