typescript 4.8.0-dev.20220627 → 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.
@@ -303,7 +303,7 @@ var ts;
303
303
  // The following is baselined as a literal template type without intervention
304
304
  /** The version of the TypeScript compiler release */
305
305
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
306
- ts.version = ts.versionMajorMinor + ".0-dev.20220627";
306
+ ts.version = ts.versionMajorMinor + ".0-dev.20220628";
307
307
  /* @internal */
308
308
  var Comparison;
309
309
  (function (Comparison) {
@@ -33153,7 +33153,7 @@ var ts;
33153
33153
  }
33154
33154
  return parseElement();
33155
33155
  }
33156
- function currentNode(parsingContext) {
33156
+ function currentNode(parsingContext, pos) {
33157
33157
  // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse.
33158
33158
  //
33159
33159
  // If there is an outstanding parse error that we've encountered, but not attached to
@@ -33166,7 +33166,7 @@ var ts;
33166
33166
  if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
33167
33167
  return undefined;
33168
33168
  }
33169
- var node = syntaxCursor.currentNode(scanner.getStartPos());
33169
+ var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos());
33170
33170
  // Can't reuse a missing node.
33171
33171
  // Can't reuse a node that intersected the change range.
33172
33172
  // Can't reuse a node that contains a parse error. This is necessary so that we
@@ -36788,24 +36788,19 @@ var ts;
36788
36788
  return modifier.kind === 135 /* DeclareKeyword */;
36789
36789
  }
36790
36790
  function parseDeclaration() {
36791
- // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner
36792
- // if we can't reuse the declaration, so that we don't do this work twice?
36793
- //
36794
36791
  // `parseListElement` attempted to get the reused node at this position,
36795
36792
  // but the ambient context flag was not yet set, so the node appeared
36796
36793
  // not reusable in that context.
36797
- var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier);
36798
- if (isAmbient) {
36799
- var node = tryReuseAmbientDeclaration();
36800
- if (node) {
36801
- return node;
36802
- }
36803
- }
36804
36794
  var pos = getNodePos();
36805
36795
  var hasJSDoc = hasPrecedingJSDocComment();
36806
36796
  var decorators = parseDecorators();
36807
36797
  var modifiers = parseModifiers();
36798
+ var isAmbient = ts.some(modifiers, isDeclareModifier);
36808
36799
  if (isAmbient) {
36800
+ var node = tryReuseAmbientDeclaration(pos);
36801
+ if (node) {
36802
+ return node;
36803
+ }
36809
36804
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36810
36805
  var m = _a[_i];
36811
36806
  m.flags |= 16777216 /* Ambient */;
@@ -36816,9 +36811,9 @@ var ts;
36816
36811
  return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
36817
36812
  }
36818
36813
  }
36819
- function tryReuseAmbientDeclaration() {
36814
+ function tryReuseAmbientDeclaration(pos) {
36820
36815
  return doInsideOfContext(16777216 /* Ambient */, function () {
36821
- var node = currentNode(parsingContext);
36816
+ var node = currentNode(parsingContext, pos);
36822
36817
  if (node) {
36823
36818
  return consumeNode(node);
36824
36819
  }
@@ -88254,13 +88249,20 @@ var ts;
88254
88249
  if (!fileToDirective) {
88255
88250
  return undefined;
88256
88251
  }
88252
+ // computed property name should use node as value
88257
88253
  // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause
88258
88254
  // qualified names can only be used as types\namespaces
88259
88255
  // identifiers are treated as values only if they appear in type queries
88260
- var meaning = 788968 /* Type */ | 1920 /* Namespace */;
88261
- if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
88256
+ var meaning;
88257
+ if (node.parent.kind === 162 /* ComputedPropertyName */) {
88262
88258
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88263
88259
  }
88260
+ else {
88261
+ meaning = 788968 /* Type */ | 1920 /* Namespace */;
88262
+ if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
88263
+ meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88264
+ }
88265
+ }
88264
88266
  var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true);
88265
88267
  return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
88266
88268
  }
@@ -111372,7 +111374,6 @@ var ts;
111372
111374
  var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
111373
111375
  var bundleBuildInfo;
111374
111376
  var emitSkipped = false;
111375
- var exportedModulesFromDeclarationEmit;
111376
111377
  // Emit each output file
111377
111378
  enter();
111378
111379
  forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
@@ -111382,7 +111383,6 @@ var ts;
111382
111383
  diagnostics: emitterDiagnostics.getDiagnostics(),
111383
111384
  emittedFiles: emittedFilesList,
111384
111385
  sourceMaps: sourceMapDataList,
111385
- exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
111386
111386
  };
111387
111387
  function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
111388
111388
  var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
@@ -111474,7 +111474,7 @@ var ts;
111474
111474
  substituteNode: transform.substituteNode,
111475
111475
  });
111476
111476
  ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
111477
- printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
111477
+ printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions);
111478
111478
  // Clean up emit nodes on parse tree
111479
111479
  transform.dispose();
111480
111480
  if (bundleBuildInfo)
@@ -111510,7 +111510,7 @@ var ts;
111510
111510
  noEmitHelpers: true,
111511
111511
  module: compilerOptions.module,
111512
111512
  target: compilerOptions.target,
111513
- sourceMap: compilerOptions.sourceMap,
111513
+ sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
111514
111514
  inlineSourceMap: compilerOptions.inlineSourceMap,
111515
111515
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111516
111516
  onlyPrintJsDocStyle: true,
@@ -111530,17 +111530,13 @@ var ts;
111530
111530
  emitSkipped = emitSkipped || declBlocked;
111531
111531
  if (!declBlocked || forceDtsEmit) {
111532
111532
  ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
111533
- printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
111534
- sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
111533
+ printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, {
111534
+ sourceMap: printerOptions.sourceMap,
111535
111535
  sourceRoot: compilerOptions.sourceRoot,
111536
111536
  mapRoot: compilerOptions.mapRoot,
111537
111537
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111538
111538
  // Explicitly do not passthru either `inline` option
111539
111539
  });
111540
- if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) {
111541
- var sourceFile = declarationTransform.transformed[0];
111542
- exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
111543
- }
111544
111540
  }
111545
111541
  declarationTransform.dispose();
111546
111542
  if (bundleBuildInfo)
@@ -111559,7 +111555,8 @@ var ts;
111559
111555
  }
111560
111556
  ts.forEachChild(node, collectLinkedAliases);
111561
111557
  }
111562
- function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
111558
+ function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) {
111559
+ var sourceFileOrBundle = transform.transformed[0];
111563
111560
  var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined;
111564
111561
  var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined;
111565
111562
  var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
@@ -111593,7 +111590,7 @@ var ts;
111593
111590
  var sourceMap = sourceMapGenerator.toString();
111594
111591
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111595
111592
  if (printer.bundleFileInfo)
111596
- printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111593
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111597
111594
  }
111598
111595
  }
111599
111596
  else {
@@ -111601,11 +111598,11 @@ var ts;
111601
111598
  }
111602
111599
  // Write the output file
111603
111600
  var text = writer.getText();
111604
- ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111601
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
111605
111602
  // 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
111606
111603
  // 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
111607
111604
  if (printer.bundleFileInfo)
111608
- printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
111605
+ printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
111609
111606
  // Reset state
111610
111607
  writer.clear();
111611
111608
  }
@@ -111770,25 +111767,25 @@ var ts;
111770
111767
  if (!jsFileText)
111771
111768
  return jsFilePath;
111772
111769
  // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
111773
- if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111770
+ if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111774
111771
  return jsFilePath;
111775
111772
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111776
111773
  // error if no source map or for now if inline sourcemap
111777
111774
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111778
111775
  return sourceMapFilePath || "inline sourcemap decoding";
111779
- if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111776
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111780
111777
  return sourceMapFilePath;
111781
111778
  // read declaration text
111782
111779
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111783
111780
  if (declarationFilePath && !declarationText)
111784
111781
  return declarationFilePath;
111785
- if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111782
+ if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111786
111783
  return declarationFilePath;
111787
111784
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111788
111785
  // error if no source map or for now if inline sourcemap
111789
111786
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111790
111787
  return declarationMapPath || "inline sourcemap decoding";
111791
- if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111788
+ if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111792
111789
  return declarationMapPath;
111793
111790
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111794
111791
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
@@ -111828,7 +111825,7 @@ var ts;
111828
111825
  newBuildInfo.program = buildInfo.program;
111829
111826
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111830
111827
  // Update the output signature
111831
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
111828
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
111832
111829
  newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111833
111830
  }
111834
111831
  // Update sourceFileInfo
@@ -120713,8 +120710,8 @@ var ts;
120713
120710
  (function (ts) {
120714
120711
  function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
120715
120712
  var outputFiles = [];
120716
- var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
120717
- return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
120713
+ var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics;
120714
+ return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics };
120718
120715
  function writeFile(fileName, text, writeByteOrderMark) {
120719
120716
  outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
120720
120717
  }
@@ -120938,23 +120935,23 @@ var ts;
120938
120935
  /**
120939
120936
  * Gets the files affected by the path from the program
120940
120937
  */
120941
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120938
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120942
120939
  var _a, _b;
120943
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120940
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
120944
120941
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120945
120942
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120946
120943
  return result;
120947
120944
  }
120948
120945
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120949
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120946
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120950
120947
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120951
120948
  if (!sourceFile) {
120952
120949
  return ts.emptyArray;
120953
120950
  }
120954
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120951
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
120955
120952
  return [sourceFile];
120956
120953
  }
120957
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120954
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
120958
120955
  }
120959
120956
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120960
120957
  function updateSignatureOfFile(state, signature, path) {
@@ -120965,7 +120962,7 @@ var ts;
120965
120962
  /**
120966
120963
  * Returns if the shape of the signature has changed since last emit
120967
120964
  */
120968
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120965
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
120969
120966
  var _a;
120970
120967
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120971
120968
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
@@ -120975,18 +120972,16 @@ var ts;
120975
120972
  var prevSignature = info.signature;
120976
120973
  var latestSignature;
120977
120974
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
120978
- var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile,
120979
- /*emitOnlyDtsFiles*/ true, cancellationToken,
120980
- /*customTransformers*/ undefined,
120981
- /*forceDtsEmit*/ true);
120982
- var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120983
- if (firstDts_1) {
120984
- 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; })); });
120985
- latestSignature = computeSignature(firstDts_1.text, computeHash);
120975
+ programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
120976
+ ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
120977
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
120986
120978
  if (latestSignature !== prevSignature) {
120987
- updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120979
+ updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
120988
120980
  }
120989
- }
120981
+ }, cancellationToken,
120982
+ /*emitOnlyDtsFiles*/ true,
120983
+ /*customTransformers*/ undefined,
120984
+ /*forceDtsEmit*/ true);
120990
120985
  }
120991
120986
  // Default is to use file version as signature
120992
120987
  if (latestSignature === undefined) {
@@ -121009,10 +121004,6 @@ var ts;
121009
121004
  return latestSignature !== prevSignature;
121010
121005
  }
121011
121006
  BuilderState.updateShapeSignature = updateShapeSignature;
121012
- function computeSignature(text, computeHash) {
121013
- return (computeHash || ts.generateDjb2Hash)(text);
121014
- }
121015
- BuilderState.computeSignature = computeSignature;
121016
121007
  /**
121017
121008
  * Coverts the declaration emit result into exported modules map
121018
121009
  */
@@ -121162,7 +121153,7 @@ var ts;
121162
121153
  /**
121163
121154
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
121164
121155
  */
121165
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
121156
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
121166
121157
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
121167
121158
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
121168
121159
  }
@@ -121182,7 +121173,7 @@ var ts;
121182
121173
  if (!seenFileNamesMap.has(currentPath)) {
121183
121174
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
121184
121175
  seenFileNamesMap.set(currentPath, currentSourceFile);
121185
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
121176
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
121186
121177
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
121187
121178
  }
121188
121179
  }
@@ -121376,7 +121367,7 @@ var ts;
121376
121367
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
121377
121368
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
121378
121369
  */
121379
- function getNextAffectedFile(state, cancellationToken, computeHash, host) {
121370
+ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
121380
121371
  var _a, _b;
121381
121372
  while (true) {
121382
121373
  var affectedFiles = state.affectedFiles;
@@ -121388,7 +121379,7 @@ var ts;
121388
121379
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
121389
121380
  // Set the next affected file as seen and remove the cached semantic diagnostics
121390
121381
  state.affectedFilesIndex = affectedFilesIndex;
121391
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121382
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121392
121383
  return affectedFile;
121393
121384
  }
121394
121385
  affectedFilesIndex++;
@@ -121416,7 +121407,7 @@ var ts;
121416
121407
  return program;
121417
121408
  }
121418
121409
  // Get next batch of affected files
121419
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
121410
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
121420
121411
  state.currentChangedFilePath = nextKey.value;
121421
121412
  state.affectedFilesIndex = 0;
121422
121413
  if (!state.seenAffectedFiles)
@@ -121467,7 +121458,7 @@ var ts;
121467
121458
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
121468
121459
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
121469
121460
  */
121470
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121461
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121471
121462
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
121472
121463
  // If affected files is everything except default library, then nothing more to do
121473
121464
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -121475,18 +121466,18 @@ var ts;
121475
121466
  // When a change affects the global scope, all files are considered to be affected without updating their signature
121476
121467
  // That means when affected file is handled, its signature can be out of date
121477
121468
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
121478
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
121469
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
121479
121470
  return;
121480
121471
  }
121481
121472
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
121482
121473
  return;
121483
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121474
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121484
121475
  }
121485
121476
  /**
121486
121477
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
121487
121478
  * Also we need to make sure signature is updated for these files
121488
121479
  */
121489
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
121480
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
121490
121481
  removeSemanticDiagnosticsOf(state, path);
121491
121482
  if (!state.changedFilesSet.has(path)) {
121492
121483
  var program = ts.Debug.checkDefined(state.program);
@@ -121497,7 +121488,7 @@ var ts;
121497
121488
  // This ensures that we dont later during incremental builds considering wrong signature.
121498
121489
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
121499
121490
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
121500
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
121491
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
121501
121492
  // If not dts emit, nothing more to do
121502
121493
  if (ts.getEmitDeclarations(state.compilerOptions)) {
121503
121494
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -121522,20 +121513,20 @@ var ts;
121522
121513
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
121523
121514
  return newSignature !== oldSignature;
121524
121515
  }
121525
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
121516
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
121526
121517
  var _a;
121527
121518
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
121528
121519
  return false;
121529
121520
  // Every file needs to be handled
121530
121521
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
121531
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
121522
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
121532
121523
  removeDiagnosticsOfLibraryFiles(state);
121533
121524
  return true;
121534
121525
  }
121535
121526
  /**
121536
121527
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
121537
121528
  */
121538
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121529
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121539
121530
  var _a;
121540
121531
  // If there was change in signature (dts output) for the changed file,
121541
121532
  // then only we need to handle pending file emit
@@ -121553,9 +121544,9 @@ var ts;
121553
121544
  var currentPath = queue.pop();
121554
121545
  if (!seenFileNamesMap.has(currentPath)) {
121555
121546
  seenFileNamesMap.set(currentPath, true);
121556
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
121547
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
121557
121548
  return;
121558
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
121549
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
121559
121550
  if (isChangedSignature(state, currentPath)) {
121560
121551
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
121561
121552
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -121567,11 +121558,11 @@ var ts;
121567
121558
  // Go through exported modules from cache first
121568
121559
  // If exported modules has path, all files referencing file exported from are affected
121569
121560
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121570
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
121561
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
121571
121562
  return true;
121572
121563
  var references = state.referencedMap.getKeys(exportedFromPath);
121573
121564
  return references && ts.forEachKey(references, function (filePath) {
121574
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121565
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121575
121566
  });
121576
121567
  });
121577
121568
  }
@@ -121579,22 +121570,22 @@ var ts;
121579
121570
  * handle dts and semantic diagnostics on file and iterate on anything that exports this file
121580
121571
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
121581
121572
  */
121582
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
121573
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121583
121574
  var _a, _b;
121584
121575
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
121585
121576
  return undefined;
121586
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
121577
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
121587
121578
  return true;
121588
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
121579
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
121589
121580
  // If exported modules has path, all files referencing file exported from are affected
121590
121581
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121591
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121582
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121592
121583
  });
121593
121584
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
121594
121585
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
121595
121586
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
121596
121587
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
121597
- state, referencingFilePath, cancellationToken, computeHash, host);
121588
+ state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
121598
121589
  });
121599
121590
  return undefined;
121600
121591
  }
@@ -121913,8 +121904,39 @@ var ts;
121913
121904
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121914
121905
  }
121915
121906
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121916
- function computeSignature(text, data, computeHash) {
121917
- return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121907
+ function getTextHandlingSourceMapForSignature(text, data) {
121908
+ return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
121909
+ }
121910
+ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
121911
+ var _a;
121912
+ text = getTextHandlingSourceMapForSignature(text, data);
121913
+ var sourceFileDirectory;
121914
+ if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
121915
+ text += data.diagnostics.map(function (diagnostic) {
121916
+ return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
121917
+ }).join("\n");
121918
+ }
121919
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
121920
+ function flattenDiagnosticMessageText(diagnostic) {
121921
+ return ts.isString(diagnostic) ?
121922
+ diagnostic :
121923
+ diagnostic === undefined ?
121924
+ "" :
121925
+ !diagnostic.next ?
121926
+ diagnostic.messageText :
121927
+ diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n");
121928
+ }
121929
+ function locationInfo(diagnostic) {
121930
+ if (diagnostic.file.resolvedPath === sourceFile.resolvedPath)
121931
+ return "(" + diagnostic.start + "," + diagnostic.length + ")";
121932
+ if (sourceFileDirectory === undefined)
121933
+ sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
121934
+ return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)) + "(" + diagnostic.start + "," + diagnostic.length + ")";
121935
+ }
121936
+ }
121937
+ ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
121938
+ function computeSignature(text, computeHash, data) {
121939
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
121918
121940
  }
121919
121941
  ts.computeSignature = computeSignature;
121920
121942
  function createBuilderProgram(kind, _a) {
@@ -121975,7 +121997,7 @@ var ts;
121975
121997
  * in that order would be used to write the files
121976
121998
  */
121977
121999
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
121978
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
122000
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
121979
122001
  var emitKind = 1 /* Full */;
121980
122002
  var isPendingEmitFile = false;
121981
122003
  if (!affected) {
@@ -122012,32 +122034,35 @@ var ts;
122012
122034
  }
122013
122035
  function getWriteFileCallback(writeFile, customTransformers) {
122014
122036
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
122015
- var _a, _b, _c;
122037
+ var _a, _b, _c, _d, _e, _f, _g;
122016
122038
  if (ts.isDeclarationFileName(fileName)) {
122017
122039
  if (!ts.outFile(state.compilerOptions)) {
122018
122040
  ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
122019
- var newSignature = void 0;
122041
+ var emitSignature = void 0;
122020
122042
  if (!customTransformers) {
122021
122043
  var file = sourceFiles[0];
122022
122044
  var info = state.fileInfos.get(file.resolvedPath);
122023
122045
  if (info.signature === file.version) {
122024
- newSignature = computeSignature(text, data, computeHash);
122025
- if (newSignature !== file.version) { // Update it
122046
+ var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
122047
+ // 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
122048
+ if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
122049
+ emitSignature = signature;
122050
+ if (signature !== file.version) { // Update it
122026
122051
  if (host.storeFilesChangingSignatureDuringEmit)
122027
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
122052
+ ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
122028
122053
  if (state.exportedModulesMap)
122029
122054
  ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
122030
122055
  if (state.affectedFiles) {
122031
122056
  // Keep old signature so we know what to undo if cancellation happens
122032
- var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
122057
+ var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath);
122033
122058
  if (existing === undefined)
122034
- (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
122035
- info.signature = newSignature;
122059
+ ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
122060
+ info.signature = signature;
122036
122061
  }
122037
122062
  else {
122038
122063
  // These are directly commited
122039
- info.signature = newSignature;
122040
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
122064
+ info.signature = signature;
122065
+ (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear();
122041
122066
  }
122042
122067
  }
122043
122068
  }
@@ -122047,16 +122072,16 @@ var ts;
122047
122072
  // and would need their d.ts change time in --build mode
122048
122073
  if (state.compilerOptions.composite) {
122049
122074
  var filePath = sourceFiles[0].resolvedPath;
122050
- var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
122051
- newSignature || (newSignature = computeSignature(text, data, computeHash));
122052
- if (newSignature !== oldSignature) {
122053
- (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
122075
+ var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
122076
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
122077
+ if (emitSignature !== oldSignature) {
122078
+ ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
122054
122079
  state.hasChangedEmitSignature = true;
122055
122080
  }
122056
122081
  }
122057
122082
  }
122058
122083
  else if (state.compilerOptions.composite) {
122059
- var newSignature = computeSignature(text, data, computeHash);
122084
+ var newSignature = computeSignature(text, computeHash, data);
122060
122085
  if (newSignature !== state.outSignature) {
122061
122086
  state.outSignature = newSignature;
122062
122087
  state.hasChangedEmitSignature = true;
@@ -122136,7 +122161,7 @@ var ts;
122136
122161
  */
122137
122162
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
122138
122163
  while (true) {
122139
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
122164
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
122140
122165
  if (!affected) {
122141
122166
  // Done
122142
122167
  return undefined;
@@ -129001,12 +129026,18 @@ var ts;
129001
129026
  // flag causes us to return the first node whose end position matches the position and which produces and acceptable token
129002
129027
  // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the
129003
129028
  // position and whose end is greater than the position.
129029
+ // There are more sophisticated end tests later, but this one is very fast
129030
+ // and allows us to skip a bunch of work
129031
+ var end = children[middle].getEnd();
129032
+ if (end < position) {
129033
+ return -1 /* LessThan */;
129034
+ }
129004
129035
  var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true);
129005
129036
  if (start > position) {
129006
129037
  return 1 /* GreaterThan */;
129007
129038
  }
129008
129039
  // first element whose start position is before the input and whose end position is after or equal to the input
129009
- if (nodeContainsPosition(children[middle])) {
129040
+ if (nodeContainsPosition(children[middle], start, end)) {
129010
129041
  if (children[middle - 1]) {
129011
129042
  // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position
129012
129043
  if (nodeContainsPosition(children[middle - 1])) {
@@ -129038,13 +129069,16 @@ var ts;
129038
129069
  case "continue-outer": continue outer;
129039
129070
  }
129040
129071
  }
129041
- function nodeContainsPosition(node) {
129042
- var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true);
129072
+ function nodeContainsPosition(node, start, end) {
129073
+ end !== null && end !== void 0 ? end : (end = node.getEnd());
129074
+ if (end < position) {
129075
+ return false;
129076
+ }
129077
+ start !== null && start !== void 0 ? start : (start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true));
129043
129078
  if (start > position) {
129044
129079
  // If this child begins after position, then all subsequent children will as well.
129045
129080
  return false;
129046
129081
  }
129047
- var end = node.getEnd();
129048
129082
  if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) {
129049
129083
  return true;
129050
129084
  }
@@ -171261,7 +171295,7 @@ var ts;
171261
171295
  }
171262
171296
  server.updateProjectIfDirty(this);
171263
171297
  this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState, /*disableUseFileVersionAsSignature*/ true);
171264
- 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; });
171298
+ 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; });
171265
171299
  };
171266
171300
  /**
171267
171301
  * Returns true if emit was conducted