typescript 4.8.0-dev.20220627 → 4.8.0-dev.20220630

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.20220630";
307
307
  /* @internal */
308
308
  var Comparison;
309
309
  (function (Comparison) {
@@ -3318,6 +3318,22 @@ var ts;
3318
3318
  return wrapFunction(deprecation, func);
3319
3319
  }
3320
3320
  Debug.deprecate = deprecate;
3321
+ function formatVariance(varianceFlags) {
3322
+ var variance = varianceFlags & 7 /* VarianceMask */;
3323
+ var result = variance === 0 /* Invariant */ ? "in out" :
3324
+ variance === 3 /* Bivariant */ ? "[bivariant]" :
3325
+ variance === 2 /* Contravariant */ ? "in" :
3326
+ variance === 1 /* Covariant */ ? "out" :
3327
+ variance === 4 /* Independent */ ? "[independent]" : "";
3328
+ if (varianceFlags & 8 /* Unmeasurable */) {
3329
+ result += " (unmeasurable)";
3330
+ }
3331
+ else if (varianceFlags & 16 /* Unreliable */) {
3332
+ result += " (unreliable)";
3333
+ }
3334
+ return result;
3335
+ }
3336
+ Debug.formatVariance = formatVariance;
3321
3337
  })(Debug = ts.Debug || (ts.Debug = {}));
3322
3338
  })(ts || (ts = {}));
3323
3339
  /* @internal */
@@ -4059,9 +4075,9 @@ var ts;
4059
4075
  eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd });
4060
4076
  }
4061
4077
  tracingEnabled.push = push;
4062
- function pop() {
4078
+ function pop(results) {
4063
4079
  ts.Debug.assert(eventStack.length > 0);
4064
- writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp());
4080
+ writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results);
4065
4081
  eventStack.length--;
4066
4082
  }
4067
4083
  tracingEnabled.pop = pop;
@@ -4075,14 +4091,15 @@ var ts;
4075
4091
  tracingEnabled.popAll = popAll;
4076
4092
  // sample every 10ms
4077
4093
  var sampleInterval = 1000 * 10;
4078
- function writeStackEvent(index, endTime) {
4094
+ function writeStackEvent(index, endTime, results) {
4079
4095
  var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd;
4080
4096
  if (separateBeginAndEnd) {
4097
+ ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`");
4081
4098
  writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
4082
4099
  }
4083
4100
  // test if [time,endTime) straddles a sampling point
4084
4101
  else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
4085
- writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time);
4102
+ writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":" + (endTime - time), time);
4086
4103
  }
4087
4104
  }
4088
4105
  function writeEvent(eventType, phase, name, args, extras, time) {
@@ -33153,7 +33170,7 @@ var ts;
33153
33170
  }
33154
33171
  return parseElement();
33155
33172
  }
33156
- function currentNode(parsingContext) {
33173
+ function currentNode(parsingContext, pos) {
33157
33174
  // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse.
33158
33175
  //
33159
33176
  // If there is an outstanding parse error that we've encountered, but not attached to
@@ -33166,7 +33183,7 @@ var ts;
33166
33183
  if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
33167
33184
  return undefined;
33168
33185
  }
33169
- var node = syntaxCursor.currentNode(scanner.getStartPos());
33186
+ var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos());
33170
33187
  // Can't reuse a missing node.
33171
33188
  // Can't reuse a node that intersected the change range.
33172
33189
  // Can't reuse a node that contains a parse error. This is necessary so that we
@@ -36788,24 +36805,19 @@ var ts;
36788
36805
  return modifier.kind === 135 /* DeclareKeyword */;
36789
36806
  }
36790
36807
  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
36808
  // `parseListElement` attempted to get the reused node at this position,
36795
36809
  // but the ambient context flag was not yet set, so the node appeared
36796
36810
  // 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
36811
  var pos = getNodePos();
36805
36812
  var hasJSDoc = hasPrecedingJSDocComment();
36806
36813
  var decorators = parseDecorators();
36807
36814
  var modifiers = parseModifiers();
36815
+ var isAmbient = ts.some(modifiers, isDeclareModifier);
36808
36816
  if (isAmbient) {
36817
+ var node = tryReuseAmbientDeclaration(pos);
36818
+ if (node) {
36819
+ return node;
36820
+ }
36809
36821
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36810
36822
  var m = _a[_i];
36811
36823
  m.flags |= 16777216 /* Ambient */;
@@ -36816,9 +36828,9 @@ var ts;
36816
36828
  return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
36817
36829
  }
36818
36830
  }
36819
- function tryReuseAmbientDeclaration() {
36831
+ function tryReuseAmbientDeclaration(pos) {
36820
36832
  return doInsideOfContext(16777216 /* Ambient */, function () {
36821
- var node = currentNode(parsingContext);
36833
+ var node = currentNode(parsingContext, pos);
36822
36834
  if (node) {
36823
36835
  return consumeNode(node);
36824
36836
  }
@@ -67703,7 +67715,7 @@ var ts;
67703
67715
  _loop_22(tp);
67704
67716
  }
67705
67717
  links.variances = variances;
67706
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
67718
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
67707
67719
  }
67708
67720
  return links.variances;
67709
67721
  }
@@ -73576,8 +73588,8 @@ var ts;
73576
73588
  var conditional = node.parent;
73577
73589
  return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
73578
73590
  }
73579
- function getContextualTypeForChildJsxExpression(node, child) {
73580
- var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
73591
+ function getContextualTypeForChildJsxExpression(node, child, contextFlags) {
73592
+ var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags);
73581
73593
  // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty)
73582
73594
  var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
73583
73595
  if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
@@ -73595,27 +73607,27 @@ var ts;
73595
73607
  }
73596
73608
  }, /*noReductions*/ true));
73597
73609
  }
73598
- function getContextualTypeForJsxExpression(node) {
73610
+ function getContextualTypeForJsxExpression(node, contextFlags) {
73599
73611
  var exprParent = node.parent;
73600
73612
  return ts.isJsxAttributeLike(exprParent)
73601
- ? getContextualType(node)
73613
+ ? getContextualType(node, contextFlags)
73602
73614
  : ts.isJsxElement(exprParent)
73603
- ? getContextualTypeForChildJsxExpression(exprParent, node)
73615
+ ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags)
73604
73616
  : undefined;
73605
73617
  }
73606
- function getContextualTypeForJsxAttribute(attribute) {
73618
+ function getContextualTypeForJsxAttribute(attribute, contextFlags) {
73607
73619
  // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type
73608
73620
  // which is a type of the parameter of the signature we are trying out.
73609
73621
  // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName
73610
73622
  if (ts.isJsxAttribute(attribute)) {
73611
- var attributesType = getApparentTypeOfContextualType(attribute.parent);
73623
+ var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags);
73612
73624
  if (!attributesType || isTypeAny(attributesType)) {
73613
73625
  return undefined;
73614
73626
  }
73615
73627
  return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
73616
73628
  }
73617
73629
  else {
73618
- return getContextualType(attribute.parent);
73630
+ return getContextualType(attribute.parent, contextFlags);
73619
73631
  }
73620
73632
  }
73621
73633
  // Return true if the given expression is possibly a discriminant value. We limit the kinds of
@@ -73776,10 +73788,10 @@ var ts;
73776
73788
  case 271 /* ExportAssignment */:
73777
73789
  return tryGetTypeFromEffectiveTypeNode(parent);
73778
73790
  case 288 /* JsxExpression */:
73779
- return getContextualTypeForJsxExpression(parent);
73791
+ return getContextualTypeForJsxExpression(parent, contextFlags);
73780
73792
  case 285 /* JsxAttribute */:
73781
73793
  case 287 /* JsxSpreadAttribute */:
73782
- return getContextualTypeForJsxAttribute(parent);
73794
+ return getContextualTypeForJsxAttribute(parent, contextFlags);
73783
73795
  case 280 /* JsxOpeningElement */:
73784
73796
  case 279 /* JsxSelfClosingElement */:
73785
73797
  return getContextualJsxElementAttributesType(parent, contextFlags);
@@ -80784,12 +80796,14 @@ var ts;
80784
80796
  error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
80785
80797
  }
80786
80798
  else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
80799
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) });
80787
80800
  var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck);
80788
80801
  var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck);
80789
80802
  var saveVarianceTypeParameter = typeParameter;
80790
80803
  varianceTypeParameter = typeParameter;
80791
80804
  checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
80792
80805
  varianceTypeParameter = saveVarianceTypeParameter;
80806
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
80793
80807
  }
80794
80808
  }
80795
80809
  }
@@ -82185,8 +82199,17 @@ var ts;
82185
82199
  }
82186
82200
  // For a union, get a union of the awaited types of each constituent.
82187
82201
  if (type.flags & 1048576 /* Union */) {
82202
+ if (awaitedTypeStack.lastIndexOf(type.id) >= 0) {
82203
+ if (errorNode) {
82204
+ error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
82205
+ }
82206
+ return undefined;
82207
+ }
82188
82208
  var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
82189
- return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
82209
+ awaitedTypeStack.push(type.id);
82210
+ var mapped = mapType(type, mapper);
82211
+ awaitedTypeStack.pop();
82212
+ return typeAsAwaitable.awaitedTypeOfType = mapped;
82190
82213
  }
82191
82214
  var thisTypeForErrorOut = { value: undefined };
82192
82215
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
@@ -88254,13 +88277,20 @@ var ts;
88254
88277
  if (!fileToDirective) {
88255
88278
  return undefined;
88256
88279
  }
88280
+ // computed property name should use node as value
88257
88281
  // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause
88258
88282
  // qualified names can only be used as types\namespaces
88259
88283
  // 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))) {
88284
+ var meaning;
88285
+ if (node.parent.kind === 162 /* ComputedPropertyName */) {
88262
88286
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88263
88287
  }
88288
+ else {
88289
+ meaning = 788968 /* Type */ | 1920 /* Namespace */;
88290
+ if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
88291
+ meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88292
+ }
88293
+ }
88264
88294
  var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true);
88265
88295
  return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
88266
88296
  }
@@ -111372,7 +111402,6 @@ var ts;
111372
111402
  var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
111373
111403
  var bundleBuildInfo;
111374
111404
  var emitSkipped = false;
111375
- var exportedModulesFromDeclarationEmit;
111376
111405
  // Emit each output file
111377
111406
  enter();
111378
111407
  forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
@@ -111382,7 +111411,6 @@ var ts;
111382
111411
  diagnostics: emitterDiagnostics.getDiagnostics(),
111383
111412
  emittedFiles: emittedFilesList,
111384
111413
  sourceMaps: sourceMapDataList,
111385
- exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
111386
111414
  };
111387
111415
  function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
111388
111416
  var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
@@ -111474,7 +111502,7 @@ var ts;
111474
111502
  substituteNode: transform.substituteNode,
111475
111503
  });
111476
111504
  ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
111477
- printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
111505
+ printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions);
111478
111506
  // Clean up emit nodes on parse tree
111479
111507
  transform.dispose();
111480
111508
  if (bundleBuildInfo)
@@ -111510,7 +111538,7 @@ var ts;
111510
111538
  noEmitHelpers: true,
111511
111539
  module: compilerOptions.module,
111512
111540
  target: compilerOptions.target,
111513
- sourceMap: compilerOptions.sourceMap,
111541
+ sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
111514
111542
  inlineSourceMap: compilerOptions.inlineSourceMap,
111515
111543
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111516
111544
  onlyPrintJsDocStyle: true,
@@ -111530,17 +111558,13 @@ var ts;
111530
111558
  emitSkipped = emitSkipped || declBlocked;
111531
111559
  if (!declBlocked || forceDtsEmit) {
111532
111560
  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,
111561
+ printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, {
111562
+ sourceMap: printerOptions.sourceMap,
111535
111563
  sourceRoot: compilerOptions.sourceRoot,
111536
111564
  mapRoot: compilerOptions.mapRoot,
111537
111565
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111538
111566
  // Explicitly do not passthru either `inline` option
111539
111567
  });
111540
- if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) {
111541
- var sourceFile = declarationTransform.transformed[0];
111542
- exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
111543
- }
111544
111568
  }
111545
111569
  declarationTransform.dispose();
111546
111570
  if (bundleBuildInfo)
@@ -111559,7 +111583,8 @@ var ts;
111559
111583
  }
111560
111584
  ts.forEachChild(node, collectLinkedAliases);
111561
111585
  }
111562
- function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
111586
+ function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) {
111587
+ var sourceFileOrBundle = transform.transformed[0];
111563
111588
  var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined;
111564
111589
  var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined;
111565
111590
  var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
@@ -111593,7 +111618,7 @@ var ts;
111593
111618
  var sourceMap = sourceMapGenerator.toString();
111594
111619
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111595
111620
  if (printer.bundleFileInfo)
111596
- printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111621
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111597
111622
  }
111598
111623
  }
111599
111624
  else {
@@ -111601,11 +111626,11 @@ var ts;
111601
111626
  }
111602
111627
  // Write the output file
111603
111628
  var text = writer.getText();
111604
- ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111629
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
111605
111630
  // 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
111631
  // 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
111632
  if (printer.bundleFileInfo)
111608
- printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
111633
+ printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
111609
111634
  // Reset state
111610
111635
  writer.clear();
111611
111636
  }
@@ -111770,25 +111795,25 @@ var ts;
111770
111795
  if (!jsFileText)
111771
111796
  return jsFilePath;
111772
111797
  // 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)
111798
+ if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111774
111799
  return jsFilePath;
111775
111800
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111776
111801
  // error if no source map or for now if inline sourcemap
111777
111802
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111778
111803
  return sourceMapFilePath || "inline sourcemap decoding";
111779
- if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111804
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111780
111805
  return sourceMapFilePath;
111781
111806
  // read declaration text
111782
111807
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111783
111808
  if (declarationFilePath && !declarationText)
111784
111809
  return declarationFilePath;
111785
- if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111810
+ if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111786
111811
  return declarationFilePath;
111787
111812
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111788
111813
  // error if no source map or for now if inline sourcemap
111789
111814
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111790
111815
  return declarationMapPath || "inline sourcemap decoding";
111791
- if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111816
+ if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111792
111817
  return declarationMapPath;
111793
111818
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111794
111819
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
@@ -111828,7 +111853,7 @@ var ts;
111828
111853
  newBuildInfo.program = buildInfo.program;
111829
111854
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111830
111855
  // Update the output signature
111831
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
111856
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
111832
111857
  newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111833
111858
  }
111834
111859
  // Update sourceFileInfo
@@ -119634,7 +119659,7 @@ var ts;
119634
119659
  }
119635
119660
  }
119636
119661
  function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
119637
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolveModuleNamesReusingOldState, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
119662
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("program" /* Program */, "processTypeReferenceDirective", { directive: typeReferenceDirective, hasResolved: !!resolvedTypeReferenceDirective, refKind: reason.kind, refPath: isReferencedFile(reason) ? reason.file : undefined });
119638
119663
  processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
119639
119664
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
119640
119665
  }
@@ -120713,8 +120738,8 @@ var ts;
120713
120738
  (function (ts) {
120714
120739
  function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
120715
120740
  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 };
120741
+ var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics;
120742
+ return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics };
120718
120743
  function writeFile(fileName, text, writeByteOrderMark) {
120719
120744
  outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
120720
120745
  }
@@ -120938,23 +120963,23 @@ var ts;
120938
120963
  /**
120939
120964
  * Gets the files affected by the path from the program
120940
120965
  */
120941
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120966
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120942
120967
  var _a, _b;
120943
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120968
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
120944
120969
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120945
120970
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120946
120971
  return result;
120947
120972
  }
120948
120973
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120949
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120974
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120950
120975
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120951
120976
  if (!sourceFile) {
120952
120977
  return ts.emptyArray;
120953
120978
  }
120954
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120979
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
120955
120980
  return [sourceFile];
120956
120981
  }
120957
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120982
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
120958
120983
  }
120959
120984
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120960
120985
  function updateSignatureOfFile(state, signature, path) {
@@ -120965,7 +120990,7 @@ var ts;
120965
120990
  /**
120966
120991
  * Returns if the shape of the signature has changed since last emit
120967
120992
  */
120968
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120993
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
120969
120994
  var _a;
120970
120995
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120971
120996
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
@@ -120975,18 +121000,16 @@ var ts;
120975
121000
  var prevSignature = info.signature;
120976
121001
  var latestSignature;
120977
121002
  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);
121003
+ programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
121004
+ ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
121005
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
120986
121006
  if (latestSignature !== prevSignature) {
120987
- updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
121007
+ updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
120988
121008
  }
120989
- }
121009
+ }, cancellationToken,
121010
+ /*emitOnlyDtsFiles*/ true,
121011
+ /*customTransformers*/ undefined,
121012
+ /*forceDtsEmit*/ true);
120990
121013
  }
120991
121014
  // Default is to use file version as signature
120992
121015
  if (latestSignature === undefined) {
@@ -121009,10 +121032,6 @@ var ts;
121009
121032
  return latestSignature !== prevSignature;
121010
121033
  }
121011
121034
  BuilderState.updateShapeSignature = updateShapeSignature;
121012
- function computeSignature(text, computeHash) {
121013
- return (computeHash || ts.generateDjb2Hash)(text);
121014
- }
121015
- BuilderState.computeSignature = computeSignature;
121016
121035
  /**
121017
121036
  * Coverts the declaration emit result into exported modules map
121018
121037
  */
@@ -121162,7 +121181,7 @@ var ts;
121162
121181
  /**
121163
121182
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
121164
121183
  */
121165
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
121184
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
121166
121185
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
121167
121186
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
121168
121187
  }
@@ -121182,7 +121201,7 @@ var ts;
121182
121201
  if (!seenFileNamesMap.has(currentPath)) {
121183
121202
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
121184
121203
  seenFileNamesMap.set(currentPath, currentSourceFile);
121185
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
121204
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
121186
121205
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
121187
121206
  }
121188
121207
  }
@@ -121376,7 +121395,7 @@ var ts;
121376
121395
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
121377
121396
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
121378
121397
  */
121379
- function getNextAffectedFile(state, cancellationToken, computeHash, host) {
121398
+ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
121380
121399
  var _a, _b;
121381
121400
  while (true) {
121382
121401
  var affectedFiles = state.affectedFiles;
@@ -121388,7 +121407,7 @@ var ts;
121388
121407
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
121389
121408
  // Set the next affected file as seen and remove the cached semantic diagnostics
121390
121409
  state.affectedFilesIndex = affectedFilesIndex;
121391
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121410
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121392
121411
  return affectedFile;
121393
121412
  }
121394
121413
  affectedFilesIndex++;
@@ -121416,7 +121435,7 @@ var ts;
121416
121435
  return program;
121417
121436
  }
121418
121437
  // Get next batch of affected files
121419
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
121438
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
121420
121439
  state.currentChangedFilePath = nextKey.value;
121421
121440
  state.affectedFilesIndex = 0;
121422
121441
  if (!state.seenAffectedFiles)
@@ -121467,7 +121486,7 @@ var ts;
121467
121486
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
121468
121487
  * 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
121488
  */
121470
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121489
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121471
121490
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
121472
121491
  // If affected files is everything except default library, then nothing more to do
121473
121492
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -121475,18 +121494,18 @@ var ts;
121475
121494
  // When a change affects the global scope, all files are considered to be affected without updating their signature
121476
121495
  // That means when affected file is handled, its signature can be out of date
121477
121496
  // 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);
121497
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
121479
121498
  return;
121480
121499
  }
121481
121500
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
121482
121501
  return;
121483
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121502
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121484
121503
  }
121485
121504
  /**
121486
121505
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
121487
121506
  * Also we need to make sure signature is updated for these files
121488
121507
  */
121489
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
121508
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
121490
121509
  removeSemanticDiagnosticsOf(state, path);
121491
121510
  if (!state.changedFilesSet.has(path)) {
121492
121511
  var program = ts.Debug.checkDefined(state.program);
@@ -121497,7 +121516,7 @@ var ts;
121497
121516
  // This ensures that we dont later during incremental builds considering wrong signature.
121498
121517
  // 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
121518
  // 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);
121519
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
121501
121520
  // If not dts emit, nothing more to do
121502
121521
  if (ts.getEmitDeclarations(state.compilerOptions)) {
121503
121522
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -121522,20 +121541,20 @@ var ts;
121522
121541
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
121523
121542
  return newSignature !== oldSignature;
121524
121543
  }
121525
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
121544
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
121526
121545
  var _a;
121527
121546
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
121528
121547
  return false;
121529
121548
  // Every file needs to be handled
121530
121549
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
121531
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
121550
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
121532
121551
  removeDiagnosticsOfLibraryFiles(state);
121533
121552
  return true;
121534
121553
  }
121535
121554
  /**
121536
121555
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
121537
121556
  */
121538
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121557
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121539
121558
  var _a;
121540
121559
  // If there was change in signature (dts output) for the changed file,
121541
121560
  // then only we need to handle pending file emit
@@ -121553,9 +121572,9 @@ var ts;
121553
121572
  var currentPath = queue.pop();
121554
121573
  if (!seenFileNamesMap.has(currentPath)) {
121555
121574
  seenFileNamesMap.set(currentPath, true);
121556
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
121575
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
121557
121576
  return;
121558
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
121577
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
121559
121578
  if (isChangedSignature(state, currentPath)) {
121560
121579
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
121561
121580
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -121567,11 +121586,11 @@ var ts;
121567
121586
  // Go through exported modules from cache first
121568
121587
  // If exported modules has path, all files referencing file exported from are affected
121569
121588
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121570
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
121589
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
121571
121590
  return true;
121572
121591
  var references = state.referencedMap.getKeys(exportedFromPath);
121573
121592
  return references && ts.forEachKey(references, function (filePath) {
121574
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121593
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121575
121594
  });
121576
121595
  });
121577
121596
  }
@@ -121579,22 +121598,22 @@ var ts;
121579
121598
  * handle dts and semantic diagnostics on file and iterate on anything that exports this file
121580
121599
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
121581
121600
  */
121582
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
121601
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121583
121602
  var _a, _b;
121584
121603
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
121585
121604
  return undefined;
121586
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
121605
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
121587
121606
  return true;
121588
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
121607
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
121589
121608
  // If exported modules has path, all files referencing file exported from are affected
121590
121609
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121591
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121610
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121592
121611
  });
121593
121612
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
121594
121613
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
121595
121614
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
121596
121615
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
121597
- state, referencingFilePath, cancellationToken, computeHash, host);
121616
+ state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
121598
121617
  });
121599
121618
  return undefined;
121600
121619
  }
@@ -121913,8 +121932,39 @@ var ts;
121913
121932
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121914
121933
  }
121915
121934
  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);
121935
+ function getTextHandlingSourceMapForSignature(text, data) {
121936
+ return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
121937
+ }
121938
+ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
121939
+ var _a;
121940
+ text = getTextHandlingSourceMapForSignature(text, data);
121941
+ var sourceFileDirectory;
121942
+ if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
121943
+ text += data.diagnostics.map(function (diagnostic) {
121944
+ return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
121945
+ }).join("\n");
121946
+ }
121947
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
121948
+ function flattenDiagnosticMessageText(diagnostic) {
121949
+ return ts.isString(diagnostic) ?
121950
+ diagnostic :
121951
+ diagnostic === undefined ?
121952
+ "" :
121953
+ !diagnostic.next ?
121954
+ diagnostic.messageText :
121955
+ diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n");
121956
+ }
121957
+ function locationInfo(diagnostic) {
121958
+ if (diagnostic.file.resolvedPath === sourceFile.resolvedPath)
121959
+ return "(" + diagnostic.start + "," + diagnostic.length + ")";
121960
+ if (sourceFileDirectory === undefined)
121961
+ sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
121962
+ return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)) + "(" + diagnostic.start + "," + diagnostic.length + ")";
121963
+ }
121964
+ }
121965
+ ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
121966
+ function computeSignature(text, computeHash, data) {
121967
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
121918
121968
  }
121919
121969
  ts.computeSignature = computeSignature;
121920
121970
  function createBuilderProgram(kind, _a) {
@@ -121975,7 +122025,7 @@ var ts;
121975
122025
  * in that order would be used to write the files
121976
122026
  */
121977
122027
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
121978
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
122028
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
121979
122029
  var emitKind = 1 /* Full */;
121980
122030
  var isPendingEmitFile = false;
121981
122031
  if (!affected) {
@@ -122012,32 +122062,35 @@ var ts;
122012
122062
  }
122013
122063
  function getWriteFileCallback(writeFile, customTransformers) {
122014
122064
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
122015
- var _a, _b, _c;
122065
+ var _a, _b, _c, _d, _e, _f, _g;
122016
122066
  if (ts.isDeclarationFileName(fileName)) {
122017
122067
  if (!ts.outFile(state.compilerOptions)) {
122018
122068
  ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
122019
- var newSignature = void 0;
122069
+ var emitSignature = void 0;
122020
122070
  if (!customTransformers) {
122021
122071
  var file = sourceFiles[0];
122022
122072
  var info = state.fileInfos.get(file.resolvedPath);
122023
122073
  if (info.signature === file.version) {
122024
- newSignature = computeSignature(text, data, computeHash);
122025
- if (newSignature !== file.version) { // Update it
122074
+ var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
122075
+ // 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
122076
+ if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
122077
+ emitSignature = signature;
122078
+ if (signature !== file.version) { // Update it
122026
122079
  if (host.storeFilesChangingSignatureDuringEmit)
122027
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
122080
+ ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
122028
122081
  if (state.exportedModulesMap)
122029
122082
  ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
122030
122083
  if (state.affectedFiles) {
122031
122084
  // 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);
122085
+ var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath);
122033
122086
  if (existing === undefined)
122034
- (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
122035
- info.signature = newSignature;
122087
+ ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
122088
+ info.signature = signature;
122036
122089
  }
122037
122090
  else {
122038
122091
  // These are directly commited
122039
- info.signature = newSignature;
122040
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
122092
+ info.signature = signature;
122093
+ (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear();
122041
122094
  }
122042
122095
  }
122043
122096
  }
@@ -122047,16 +122100,16 @@ var ts;
122047
122100
  // and would need their d.ts change time in --build mode
122048
122101
  if (state.compilerOptions.composite) {
122049
122102
  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);
122103
+ var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
122104
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
122105
+ if (emitSignature !== oldSignature) {
122106
+ ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
122054
122107
  state.hasChangedEmitSignature = true;
122055
122108
  }
122056
122109
  }
122057
122110
  }
122058
122111
  else if (state.compilerOptions.composite) {
122059
- var newSignature = computeSignature(text, data, computeHash);
122112
+ var newSignature = computeSignature(text, computeHash, data);
122060
122113
  if (newSignature !== state.outSignature) {
122061
122114
  state.outSignature = newSignature;
122062
122115
  state.hasChangedEmitSignature = true;
@@ -122136,7 +122189,7 @@ var ts;
122136
122189
  */
122137
122190
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
122138
122191
  while (true) {
122139
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
122192
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
122140
122193
  if (!affected) {
122141
122194
  // Done
122142
122195
  return undefined;
@@ -129001,12 +129054,18 @@ var ts;
129001
129054
  // flag causes us to return the first node whose end position matches the position and which produces and acceptable token
129002
129055
  // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the
129003
129056
  // position and whose end is greater than the position.
129057
+ // There are more sophisticated end tests later, but this one is very fast
129058
+ // and allows us to skip a bunch of work
129059
+ var end = children[middle].getEnd();
129060
+ if (end < position) {
129061
+ return -1 /* LessThan */;
129062
+ }
129004
129063
  var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true);
129005
129064
  if (start > position) {
129006
129065
  return 1 /* GreaterThan */;
129007
129066
  }
129008
129067
  // 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])) {
129068
+ if (nodeContainsPosition(children[middle], start, end)) {
129010
129069
  if (children[middle - 1]) {
129011
129070
  // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position
129012
129071
  if (nodeContainsPosition(children[middle - 1])) {
@@ -129038,13 +129097,16 @@ var ts;
129038
129097
  case "continue-outer": continue outer;
129039
129098
  }
129040
129099
  }
129041
- function nodeContainsPosition(node) {
129042
- var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true);
129100
+ function nodeContainsPosition(node, start, end) {
129101
+ end !== null && end !== void 0 ? end : (end = node.getEnd());
129102
+ if (end < position) {
129103
+ return false;
129104
+ }
129105
+ start !== null && start !== void 0 ? start : (start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true));
129043
129106
  if (start > position) {
129044
129107
  // If this child begins after position, then all subsequent children will as well.
129045
129108
  return false;
129046
129109
  }
129047
- var end = node.getEnd();
129048
129110
  if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) {
129049
129111
  return true;
129050
129112
  }
@@ -133941,37 +134003,36 @@ var ts;
133941
134003
  }
133942
134004
  }
133943
134005
  var entries = ts.createSortedArray();
133944
- if (isUncheckedFile(sourceFile, compilerOptions)) {
133945
- var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
133946
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
133947
- getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
133948
- }
133949
- else {
133950
- if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
133951
- return undefined;
133952
- }
133953
- getCompletionEntriesFromSymbols(symbols, entries,
133954
- /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
134006
+ var isChecked = isCheckedFile(sourceFile, compilerOptions);
134007
+ if (isChecked && !isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
134008
+ return undefined;
133955
134009
  }
134010
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
134011
+ /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextMap, isJsxIdentifierExpected, isRightOfOpenTag);
133956
134012
  if (keywordFilters !== 0 /* None */) {
133957
- var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
133958
134013
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
133959
134014
  var keywordEntry = _a[_i];
133960
- if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) {
134015
+ if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) {
134016
+ uniqueNames.add(keywordEntry.name);
133961
134017
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133962
134018
  }
133963
134019
  }
133964
134020
  }
133965
- var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
133966
134021
  for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
133967
134022
  var keywordEntry = _c[_b];
133968
- if (!entryNames.has(keywordEntry.name)) {
134023
+ if (!uniqueNames.has(keywordEntry.name)) {
134024
+ uniqueNames.add(keywordEntry.name);
133969
134025
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133970
134026
  }
133971
134027
  }
133972
134028
  for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
133973
134029
  var literal = literals_1[_d];
133974
- ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
134030
+ var literalEntry = createCompletionEntryForLiteral(sourceFile, preferences, literal);
134031
+ uniqueNames.add(literalEntry.name);
134032
+ ts.insertSorted(entries, literalEntry, compareCompletionEntries, /*allowDuplicates*/ true);
134033
+ }
134034
+ if (!isChecked) {
134035
+ getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
133975
134036
  }
133976
134037
  return {
133977
134038
  flags: completionData.flags,
@@ -133983,8 +134044,8 @@ var ts;
133983
134044
  entries: entries,
133984
134045
  };
133985
134046
  }
133986
- function isUncheckedFile(sourceFile, compilerOptions) {
133987
- return ts.isSourceFileJS(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions);
134047
+ function isCheckedFile(sourceFile, compilerOptions) {
134048
+ return !ts.isSourceFileJS(sourceFile) || !!ts.isCheckJsEnabledForFile(sourceFile, compilerOptions);
133988
134049
  }
133989
134050
  function isMemberCompletionKind(kind) {
133990
134051
  switch (kind) {
@@ -134942,7 +135003,7 @@ var ts;
134942
135003
  }
134943
135004
  function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
134944
135005
  var typeChecker = program.getTypeChecker();
134945
- var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
135006
+ var inCheckedFile = isCheckedFile(sourceFile, compilerOptions);
134946
135007
  var start = ts.timestamp();
134947
135008
  var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
134948
135009
  // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
@@ -135358,15 +135419,7 @@ var ts;
135358
135419
  isNewIdentifierLocation = true;
135359
135420
  }
135360
135421
  var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
135361
- if (inUncheckedFile) {
135362
- // In javascript files, for union types, we don't just get the members that
135363
- // the individual types have in common, we also include all the members that
135364
- // each individual type has. This is because we're going to add all identifiers
135365
- // anyways. So we might as well elevate the members that were at least part
135366
- // of the individual types to a higher status since we know what they are.
135367
- symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); }));
135368
- }
135369
- else {
135422
+ if (inCheckedFile) {
135370
135423
  for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) {
135371
135424
  var symbol = _a[_i];
135372
135425
  if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) {
@@ -135374,6 +135427,14 @@ var ts;
135374
135427
  }
135375
135428
  }
135376
135429
  }
135430
+ else {
135431
+ // In javascript files, for union types, we don't just get the members that
135432
+ // the individual types have in common, we also include all the members that
135433
+ // each individual type has. This is because we're going to add all identifiers
135434
+ // anyways. So we might as well elevate the members that were at least part
135435
+ // of the individual types to a higher status since we know what they are.
135436
+ symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); }));
135437
+ }
135377
135438
  if (insertAwait && preferences.includeCompletionsWithInsertText) {
135378
135439
  var promiseType = typeChecker.getPromisedTypeOfPromise(type);
135379
135440
  if (promiseType) {
@@ -155736,7 +155797,7 @@ var ts;
155736
155797
  if (!newConstraint)
155737
155798
  return;
155738
155799
  var newConstraintText = newConstraint[1];
155739
- changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
155800
+ changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
155740
155801
  }
155741
155802
  function findAncestorMatchingSpan(sourceFile, span) {
155742
155803
  var token = ts.getTokenAtPosition(sourceFile, span.start);
@@ -171261,7 +171322,7 @@ var ts;
171261
171322
  }
171262
171323
  server.updateProjectIfDirty(this);
171263
171324
  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; });
171325
+ 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
171326
  };
171266
171327
  /**
171267
171328
  * Returns true if emit was conducted