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.
package/lib/tsserver.js CHANGED
@@ -109,7 +109,7 @@ var ts;
109
109
  // The following is baselined as a literal template type without intervention
110
110
  /** The version of the TypeScript compiler release */
111
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
112
- ts.version = ts.versionMajorMinor + ".0-dev.20220627";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220630";
113
113
  /* @internal */
114
114
  var Comparison;
115
115
  (function (Comparison) {
@@ -3124,6 +3124,22 @@ var ts;
3124
3124
  return wrapFunction(deprecation, func);
3125
3125
  }
3126
3126
  Debug.deprecate = deprecate;
3127
+ function formatVariance(varianceFlags) {
3128
+ var variance = varianceFlags & 7 /* VarianceMask */;
3129
+ var result = variance === 0 /* Invariant */ ? "in out" :
3130
+ variance === 3 /* Bivariant */ ? "[bivariant]" :
3131
+ variance === 2 /* Contravariant */ ? "in" :
3132
+ variance === 1 /* Covariant */ ? "out" :
3133
+ variance === 4 /* Independent */ ? "[independent]" : "";
3134
+ if (varianceFlags & 8 /* Unmeasurable */) {
3135
+ result += " (unmeasurable)";
3136
+ }
3137
+ else if (varianceFlags & 16 /* Unreliable */) {
3138
+ result += " (unreliable)";
3139
+ }
3140
+ return result;
3141
+ }
3142
+ Debug.formatVariance = formatVariance;
3127
3143
  })(Debug = ts.Debug || (ts.Debug = {}));
3128
3144
  })(ts || (ts = {}));
3129
3145
  /* @internal */
@@ -3865,9 +3881,9 @@ var ts;
3865
3881
  eventStack.push({ phase: phase, name: name, args: args, time: 1000 * ts.timestamp(), separateBeginAndEnd: separateBeginAndEnd });
3866
3882
  }
3867
3883
  tracingEnabled.push = push;
3868
- function pop() {
3884
+ function pop(results) {
3869
3885
  ts.Debug.assert(eventStack.length > 0);
3870
- writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp());
3886
+ writeStackEvent(eventStack.length - 1, 1000 * ts.timestamp(), results);
3871
3887
  eventStack.length--;
3872
3888
  }
3873
3889
  tracingEnabled.pop = pop;
@@ -3881,14 +3897,15 @@ var ts;
3881
3897
  tracingEnabled.popAll = popAll;
3882
3898
  // sample every 10ms
3883
3899
  var sampleInterval = 1000 * 10;
3884
- function writeStackEvent(index, endTime) {
3900
+ function writeStackEvent(index, endTime, results) {
3885
3901
  var _a = eventStack[index], phase = _a.phase, name = _a.name, args = _a.args, time = _a.time, separateBeginAndEnd = _a.separateBeginAndEnd;
3886
3902
  if (separateBeginAndEnd) {
3903
+ ts.Debug.assert(!results, "`results` are not supported for events with `separateBeginAndEnd`");
3887
3904
  writeEvent("E", phase, name, args, /*extras*/ undefined, endTime);
3888
3905
  }
3889
3906
  // test if [time,endTime) straddles a sampling point
3890
3907
  else if (sampleInterval - (time % sampleInterval) <= endTime - time) {
3891
- writeEvent("X", phase, name, args, "\"dur\":" + (endTime - time), time);
3908
+ writeEvent("X", phase, name, __assign(__assign({}, args), { results: results }), "\"dur\":" + (endTime - time), time);
3892
3909
  }
3893
3910
  }
3894
3911
  function writeEvent(eventType, phase, name, args, extras, time) {
@@ -32959,7 +32976,7 @@ var ts;
32959
32976
  }
32960
32977
  return parseElement();
32961
32978
  }
32962
- function currentNode(parsingContext) {
32979
+ function currentNode(parsingContext, pos) {
32963
32980
  // If we don't have a cursor or the parsing context isn't reusable, there's nothing to reuse.
32964
32981
  //
32965
32982
  // If there is an outstanding parse error that we've encountered, but not attached to
@@ -32972,7 +32989,7 @@ var ts;
32972
32989
  if (!syntaxCursor || !isReusableParsingContext(parsingContext) || parseErrorBeforeNextFinishedNode) {
32973
32990
  return undefined;
32974
32991
  }
32975
- var node = syntaxCursor.currentNode(scanner.getStartPos());
32992
+ var node = syntaxCursor.currentNode(pos !== null && pos !== void 0 ? pos : scanner.getStartPos());
32976
32993
  // Can't reuse a missing node.
32977
32994
  // Can't reuse a node that intersected the change range.
32978
32995
  // Can't reuse a node that contains a parse error. This is necessary so that we
@@ -36594,24 +36611,19 @@ var ts;
36594
36611
  return modifier.kind === 135 /* DeclareKeyword */;
36595
36612
  }
36596
36613
  function parseDeclaration() {
36597
- // TODO: Can we hold onto the parsed decorators/modifiers and advance the scanner
36598
- // if we can't reuse the declaration, so that we don't do this work twice?
36599
- //
36600
36614
  // `parseListElement` attempted to get the reused node at this position,
36601
36615
  // but the ambient context flag was not yet set, so the node appeared
36602
36616
  // not reusable in that context.
36603
- var isAmbient = ts.some(lookAhead(function () { return (parseDecorators(), parseModifiers()); }), isDeclareModifier);
36604
- if (isAmbient) {
36605
- var node = tryReuseAmbientDeclaration();
36606
- if (node) {
36607
- return node;
36608
- }
36609
- }
36610
36617
  var pos = getNodePos();
36611
36618
  var hasJSDoc = hasPrecedingJSDocComment();
36612
36619
  var decorators = parseDecorators();
36613
36620
  var modifiers = parseModifiers();
36621
+ var isAmbient = ts.some(modifiers, isDeclareModifier);
36614
36622
  if (isAmbient) {
36623
+ var node = tryReuseAmbientDeclaration(pos);
36624
+ if (node) {
36625
+ return node;
36626
+ }
36615
36627
  for (var _i = 0, _a = modifiers; _i < _a.length; _i++) {
36616
36628
  var m = _a[_i];
36617
36629
  m.flags |= 16777216 /* Ambient */;
@@ -36622,9 +36634,9 @@ var ts;
36622
36634
  return parseDeclarationWorker(pos, hasJSDoc, decorators, modifiers);
36623
36635
  }
36624
36636
  }
36625
- function tryReuseAmbientDeclaration() {
36637
+ function tryReuseAmbientDeclaration(pos) {
36626
36638
  return doInsideOfContext(16777216 /* Ambient */, function () {
36627
- var node = currentNode(parsingContext);
36639
+ var node = currentNode(parsingContext, pos);
36628
36640
  if (node) {
36629
36641
  return consumeNode(node);
36630
36642
  }
@@ -67509,7 +67521,7 @@ var ts;
67509
67521
  _loop_22(tp);
67510
67522
  }
67511
67523
  links.variances = variances;
67512
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
67524
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop({ variances: variances.map(ts.Debug.formatVariance) });
67513
67525
  }
67514
67526
  return links.variances;
67515
67527
  }
@@ -73382,8 +73394,8 @@ var ts;
73382
73394
  var conditional = node.parent;
73383
73395
  return node === conditional.whenTrue || node === conditional.whenFalse ? getContextualType(conditional, contextFlags) : undefined;
73384
73396
  }
73385
- function getContextualTypeForChildJsxExpression(node, child) {
73386
- var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName);
73397
+ function getContextualTypeForChildJsxExpression(node, child, contextFlags) {
73398
+ var attributesType = getApparentTypeOfContextualType(node.openingElement.tagName, contextFlags);
73387
73399
  // JSX expression is in children of JSX Element, we will look for an "children" attribute (we get the name from JSX.ElementAttributesProperty)
73388
73400
  var jsxChildrenPropertyName = getJsxElementChildrenPropertyName(getJsxNamespaceAt(node));
73389
73401
  if (!(attributesType && !isTypeAny(attributesType) && jsxChildrenPropertyName && jsxChildrenPropertyName !== "")) {
@@ -73401,27 +73413,27 @@ var ts;
73401
73413
  }
73402
73414
  }, /*noReductions*/ true));
73403
73415
  }
73404
- function getContextualTypeForJsxExpression(node) {
73416
+ function getContextualTypeForJsxExpression(node, contextFlags) {
73405
73417
  var exprParent = node.parent;
73406
73418
  return ts.isJsxAttributeLike(exprParent)
73407
- ? getContextualType(node)
73419
+ ? getContextualType(node, contextFlags)
73408
73420
  : ts.isJsxElement(exprParent)
73409
- ? getContextualTypeForChildJsxExpression(exprParent, node)
73421
+ ? getContextualTypeForChildJsxExpression(exprParent, node, contextFlags)
73410
73422
  : undefined;
73411
73423
  }
73412
- function getContextualTypeForJsxAttribute(attribute) {
73424
+ function getContextualTypeForJsxAttribute(attribute, contextFlags) {
73413
73425
  // When we trying to resolve JsxOpeningLikeElement as a stateless function element, we will already give its attributes a contextual type
73414
73426
  // which is a type of the parameter of the signature we are trying out.
73415
73427
  // If there is no contextual type (e.g. we are trying to resolve stateful component), get attributes type from resolving element's tagName
73416
73428
  if (ts.isJsxAttribute(attribute)) {
73417
- var attributesType = getApparentTypeOfContextualType(attribute.parent);
73429
+ var attributesType = getApparentTypeOfContextualType(attribute.parent, contextFlags);
73418
73430
  if (!attributesType || isTypeAny(attributesType)) {
73419
73431
  return undefined;
73420
73432
  }
73421
73433
  return getTypeOfPropertyOfContextualType(attributesType, attribute.name.escapedText);
73422
73434
  }
73423
73435
  else {
73424
- return getContextualType(attribute.parent);
73436
+ return getContextualType(attribute.parent, contextFlags);
73425
73437
  }
73426
73438
  }
73427
73439
  // Return true if the given expression is possibly a discriminant value. We limit the kinds of
@@ -73582,10 +73594,10 @@ var ts;
73582
73594
  case 271 /* ExportAssignment */:
73583
73595
  return tryGetTypeFromEffectiveTypeNode(parent);
73584
73596
  case 288 /* JsxExpression */:
73585
- return getContextualTypeForJsxExpression(parent);
73597
+ return getContextualTypeForJsxExpression(parent, contextFlags);
73586
73598
  case 285 /* JsxAttribute */:
73587
73599
  case 287 /* JsxSpreadAttribute */:
73588
- return getContextualTypeForJsxAttribute(parent);
73600
+ return getContextualTypeForJsxAttribute(parent, contextFlags);
73589
73601
  case 280 /* JsxOpeningElement */:
73590
73602
  case 279 /* JsxSelfClosingElement */:
73591
73603
  return getContextualJsxElementAttributesType(parent, contextFlags);
@@ -80590,12 +80602,14 @@ var ts;
80590
80602
  error(node, ts.Diagnostics.Variance_annotations_are_only_supported_in_type_aliases_for_object_function_constructor_and_mapped_types);
80591
80603
  }
80592
80604
  else if (modifiers === 32768 /* In */ || modifiers === 65536 /* Out */) {
80605
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("checkTypes" /* CheckTypes */, "checkTypeParameterDeferred", { parent: getTypeId(getDeclaredTypeOfSymbol(symbol)), id: getTypeId(typeParameter) });
80593
80606
  var source = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSubTypeForCheck : markerSuperTypeForCheck);
80594
80607
  var target = createMarkerType(symbol, typeParameter, modifiers === 65536 /* Out */ ? markerSuperTypeForCheck : markerSubTypeForCheck);
80595
80608
  var saveVarianceTypeParameter = typeParameter;
80596
80609
  varianceTypeParameter = typeParameter;
80597
80610
  checkTypeAssignableTo(source, target, node, ts.Diagnostics.Type_0_is_not_assignable_to_type_1_as_implied_by_variance_annotation);
80598
80611
  varianceTypeParameter = saveVarianceTypeParameter;
80612
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
80599
80613
  }
80600
80614
  }
80601
80615
  }
@@ -81991,8 +82005,17 @@ var ts;
81991
82005
  }
81992
82006
  // For a union, get a union of the awaited types of each constituent.
81993
82007
  if (type.flags & 1048576 /* Union */) {
82008
+ if (awaitedTypeStack.lastIndexOf(type.id) >= 0) {
82009
+ if (errorNode) {
82010
+ error(errorNode, ts.Diagnostics.Type_is_referenced_directly_or_indirectly_in_the_fulfillment_callback_of_its_own_then_method);
82011
+ }
82012
+ return undefined;
82013
+ }
81994
82014
  var mapper = errorNode ? function (constituentType) { return getAwaitedTypeNoAlias(constituentType, errorNode, diagnosticMessage, arg0); } : getAwaitedTypeNoAlias;
81995
- return typeAsAwaitable.awaitedTypeOfType = mapType(type, mapper);
82015
+ awaitedTypeStack.push(type.id);
82016
+ var mapped = mapType(type, mapper);
82017
+ awaitedTypeStack.pop();
82018
+ return typeAsAwaitable.awaitedTypeOfType = mapped;
81996
82019
  }
81997
82020
  var thisTypeForErrorOut = { value: undefined };
81998
82021
  var promisedType = getPromisedTypeOfPromise(type, /*errorNode*/ undefined, thisTypeForErrorOut);
@@ -88060,13 +88083,20 @@ var ts;
88060
88083
  if (!fileToDirective) {
88061
88084
  return undefined;
88062
88085
  }
88086
+ // computed property name should use node as value
88063
88087
  // property access can only be used as values, or types when within an expression with type arguments inside a heritage clause
88064
88088
  // qualified names can only be used as types\namespaces
88065
88089
  // identifiers are treated as values only if they appear in type queries
88066
- var meaning = 788968 /* Type */ | 1920 /* Namespace */;
88067
- if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
88090
+ var meaning;
88091
+ if (node.parent.kind === 162 /* ComputedPropertyName */) {
88068
88092
  meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88069
88093
  }
88094
+ else {
88095
+ meaning = 788968 /* Type */ | 1920 /* Namespace */;
88096
+ if ((node.kind === 79 /* Identifier */ && isInTypeQuery(node)) || (node.kind === 206 /* PropertyAccessExpression */ && !isInHeritageClause(node))) {
88097
+ meaning = 111551 /* Value */ | 1048576 /* ExportValue */;
88098
+ }
88099
+ }
88070
88100
  var symbol = resolveEntityName(node, meaning, /*ignoreErrors*/ true);
88071
88101
  return symbol && symbol !== unknownSymbol ? getTypeReferenceDirectivesForSymbol(symbol, meaning) : undefined;
88072
88102
  }
@@ -111178,7 +111208,6 @@ var ts;
111178
111208
  var _b = ts.performance.createTimer("printTime", "beforePrint", "afterPrint"), enter = _b.enter, exit = _b.exit;
111179
111209
  var bundleBuildInfo;
111180
111210
  var emitSkipped = false;
111181
- var exportedModulesFromDeclarationEmit;
111182
111211
  // Emit each output file
111183
111212
  enter();
111184
111213
  forEachEmittedFile(host, emitSourceFileOrBundle, ts.getSourceFilesToEmit(host, targetSourceFile, forceDtsEmit), forceDtsEmit, onlyBuildInfo, !targetSourceFile);
@@ -111188,7 +111217,6 @@ var ts;
111188
111217
  diagnostics: emitterDiagnostics.getDiagnostics(),
111189
111218
  emittedFiles: emittedFilesList,
111190
111219
  sourceMaps: sourceMapDataList,
111191
- exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit
111192
111220
  };
111193
111221
  function emitSourceFileOrBundle(_a, sourceFileOrBundle) {
111194
111222
  var jsFilePath = _a.jsFilePath, sourceMapFilePath = _a.sourceMapFilePath, declarationFilePath = _a.declarationFilePath, declarationMapPath = _a.declarationMapPath, buildInfoPath = _a.buildInfoPath;
@@ -111280,7 +111308,7 @@ var ts;
111280
111308
  substituteNode: transform.substituteNode,
111281
111309
  });
111282
111310
  ts.Debug.assert(transform.transformed.length === 1, "Should only see one output from the transform");
111283
- printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform.transformed[0], printer, compilerOptions);
111311
+ printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, compilerOptions);
111284
111312
  // Clean up emit nodes on parse tree
111285
111313
  transform.dispose();
111286
111314
  if (bundleBuildInfo)
@@ -111316,7 +111344,7 @@ var ts;
111316
111344
  noEmitHelpers: true,
111317
111345
  module: compilerOptions.module,
111318
111346
  target: compilerOptions.target,
111319
- sourceMap: compilerOptions.sourceMap,
111347
+ sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
111320
111348
  inlineSourceMap: compilerOptions.inlineSourceMap,
111321
111349
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111322
111350
  onlyPrintJsDocStyle: true,
@@ -111336,17 +111364,13 @@ var ts;
111336
111364
  emitSkipped = emitSkipped || declBlocked;
111337
111365
  if (!declBlocked || forceDtsEmit) {
111338
111366
  ts.Debug.assert(declarationTransform.transformed.length === 1, "Should only see one output from the decl transform");
111339
- printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform.transformed[0], declarationPrinter, {
111340
- sourceMap: !forceDtsEmit && compilerOptions.declarationMap,
111367
+ printSourceFileOrBundle(declarationFilePath, declarationMapPath, declarationTransform, declarationPrinter, {
111368
+ sourceMap: printerOptions.sourceMap,
111341
111369
  sourceRoot: compilerOptions.sourceRoot,
111342
111370
  mapRoot: compilerOptions.mapRoot,
111343
111371
  extendedDiagnostics: compilerOptions.extendedDiagnostics,
111344
111372
  // Explicitly do not passthru either `inline` option
111345
111373
  });
111346
- if (forceDtsEmit && declarationTransform.transformed[0].kind === 305 /* SourceFile */) {
111347
- var sourceFile = declarationTransform.transformed[0];
111348
- exportedModulesFromDeclarationEmit = sourceFile.exportedModulesFromDeclarationEmit;
111349
- }
111350
111374
  }
111351
111375
  declarationTransform.dispose();
111352
111376
  if (bundleBuildInfo)
@@ -111365,7 +111389,8 @@ var ts;
111365
111389
  }
111366
111390
  ts.forEachChild(node, collectLinkedAliases);
111367
111391
  }
111368
- function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, sourceFileOrBundle, printer, mapOptions) {
111392
+ function printSourceFileOrBundle(jsFilePath, sourceMapFilePath, transform, printer, mapOptions) {
111393
+ var sourceFileOrBundle = transform.transformed[0];
111369
111394
  var bundle = sourceFileOrBundle.kind === 306 /* Bundle */ ? sourceFileOrBundle : undefined;
111370
111395
  var sourceFile = sourceFileOrBundle.kind === 305 /* SourceFile */ ? sourceFileOrBundle : undefined;
111371
111396
  var sourceFiles = bundle ? bundle.sourceFiles : [sourceFile];
@@ -111399,7 +111424,7 @@ var ts;
111399
111424
  var sourceMap = sourceMapGenerator.toString();
111400
111425
  ts.writeFile(host, emitterDiagnostics, sourceMapFilePath, sourceMap, /*writeByteOrderMark*/ false, sourceFiles);
111401
111426
  if (printer.bundleFileInfo)
111402
- printer.bundleFileInfo.mapHash = ts.BuilderState.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111427
+ printer.bundleFileInfo.mapHash = ts.computeSignature(sourceMap, ts.maybeBind(host, host.createHash));
111403
111428
  }
111404
111429
  }
111405
111430
  else {
@@ -111407,11 +111432,11 @@ var ts;
111407
111432
  }
111408
111433
  // Write the output file
111409
111434
  var text = writer.getText();
111410
- ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
111435
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, text, !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos, diagnostics: transform.diagnostics });
111411
111436
  // We store the hash of the text written in the buildinfo to ensure that text of the referenced d.ts file is same as whats in the buildinfo
111412
111437
  // This is needed because incremental can be toggled between two runs and we might use stale file text to do text manipulation in prepend mode
111413
111438
  if (printer.bundleFileInfo)
111414
- printer.bundleFileInfo.hash = ts.BuilderState.computeSignature(text, ts.maybeBind(host, host.createHash));
111439
+ printer.bundleFileInfo.hash = ts.computeSignature(text, ts.maybeBind(host, host.createHash));
111415
111440
  // Reset state
111416
111441
  writer.clear();
111417
111442
  }
@@ -111576,25 +111601,25 @@ var ts;
111576
111601
  if (!jsFileText)
111577
111602
  return jsFilePath;
111578
111603
  // If the jsFileText is not same has what it was created with, tsbuildinfo is stale so dont use it
111579
- if (ts.BuilderState.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111604
+ if (ts.computeSignature(jsFileText, createHash) !== buildInfo.bundle.js.hash)
111580
111605
  return jsFilePath;
111581
111606
  var sourceMapText = sourceMapFilePath && host.readFile(sourceMapFilePath);
111582
111607
  // error if no source map or for now if inline sourcemap
111583
111608
  if ((sourceMapFilePath && !sourceMapText) || config.options.inlineSourceMap)
111584
111609
  return sourceMapFilePath || "inline sourcemap decoding";
111585
- if (sourceMapFilePath && ts.BuilderState.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111610
+ if (sourceMapFilePath && ts.computeSignature(sourceMapText, createHash) !== buildInfo.bundle.js.mapHash)
111586
111611
  return sourceMapFilePath;
111587
111612
  // read declaration text
111588
111613
  var declarationText = declarationFilePath && host.readFile(declarationFilePath);
111589
111614
  if (declarationFilePath && !declarationText)
111590
111615
  return declarationFilePath;
111591
- if (declarationFilePath && ts.BuilderState.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111616
+ if (declarationFilePath && ts.computeSignature(declarationText, createHash) !== buildInfo.bundle.dts.hash)
111592
111617
  return declarationFilePath;
111593
111618
  var declarationMapText = declarationMapPath && host.readFile(declarationMapPath);
111594
111619
  // error if no source map or for now if inline sourcemap
111595
111620
  if ((declarationMapPath && !declarationMapText) || config.options.inlineSourceMap)
111596
111621
  return declarationMapPath || "inline sourcemap decoding";
111597
- if (declarationMapPath && ts.BuilderState.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111622
+ if (declarationMapPath && ts.computeSignature(declarationMapText, createHash) !== buildInfo.bundle.dts.mapHash)
111598
111623
  return declarationMapPath;
111599
111624
  var buildInfoDirectory = ts.getDirectoryPath(ts.getNormalizedAbsolutePath(buildInfoPath, host.getCurrentDirectory()));
111600
111625
  var ownPrependInput = ts.createInputFiles(jsFileText, declarationText, sourceMapFilePath, sourceMapText, declarationMapPath, declarationMapText, jsFilePath, declarationFilePath, buildInfoPath, buildInfo,
@@ -111634,7 +111659,7 @@ var ts;
111634
111659
  newBuildInfo.program = buildInfo.program;
111635
111660
  if (newBuildInfo.program && changedDtsText !== undefined && config.options.composite) {
111636
111661
  // Update the output signature
111637
- newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, changedDtsData, createHash);
111662
+ newBuildInfo.program.outSignature = ts.computeSignature(changedDtsText, createHash, changedDtsData);
111638
111663
  newBuildInfo.program.dtsChangeTime = ts.getCurrentTime(host).getTime();
111639
111664
  }
111640
111665
  // Update sourceFileInfo
@@ -119440,7 +119465,7 @@ var ts;
119440
119465
  }
119441
119466
  }
119442
119467
  function processTypeReferenceDirective(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason) {
119443
- 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 });
119468
+ 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 });
119444
119469
  processTypeReferenceDirectiveWorker(typeReferenceDirective, mode, resolvedTypeReferenceDirective, reason);
119445
119470
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
119446
119471
  }
@@ -120519,8 +120544,8 @@ var ts;
120519
120544
  (function (ts) {
120520
120545
  function getFileEmitOutput(program, sourceFile, emitOnlyDtsFiles, cancellationToken, customTransformers, forceDtsEmit) {
120521
120546
  var outputFiles = [];
120522
- var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics, exportedModulesFromDeclarationEmit = _a.exportedModulesFromDeclarationEmit;
120523
- return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics, exportedModulesFromDeclarationEmit: exportedModulesFromDeclarationEmit };
120547
+ var _a = program.emit(sourceFile, writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers, forceDtsEmit), emitSkipped = _a.emitSkipped, diagnostics = _a.diagnostics;
120548
+ return { outputFiles: outputFiles, emitSkipped: emitSkipped, diagnostics: diagnostics };
120524
120549
  function writeFile(fileName, text, writeByteOrderMark) {
120525
120550
  outputFiles.push({ name: fileName, writeByteOrderMark: writeByteOrderMark, text: text });
120526
120551
  }
@@ -120744,23 +120769,23 @@ var ts;
120744
120769
  /**
120745
120770
  * Gets the files affected by the path from the program
120746
120771
  */
120747
- function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash) {
120772
+ function getFilesAffectedBy(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120748
120773
  var _a, _b;
120749
- var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash);
120774
+ var result = getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName);
120750
120775
  (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.clear();
120751
120776
  (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
120752
120777
  return result;
120753
120778
  }
120754
120779
  BuilderState.getFilesAffectedBy = getFilesAffectedBy;
120755
- function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash) {
120780
+ function getFilesAffectedByWithOldState(state, programOfThisState, path, cancellationToken, computeHash, getCanonicalFileName) {
120756
120781
  var sourceFile = programOfThisState.getSourceFileByPath(path);
120757
120782
  if (!sourceFile) {
120758
120783
  return ts.emptyArray;
120759
120784
  }
120760
- if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash)) {
120785
+ if (!updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
120761
120786
  return [sourceFile];
120762
120787
  }
120763
- return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash);
120788
+ return (state.referencedMap ? getFilesAffectedByUpdatedShapeWhenModuleEmit : getFilesAffectedByUpdatedShapeWhenNonModuleEmit)(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName);
120764
120789
  }
120765
120790
  BuilderState.getFilesAffectedByWithOldState = getFilesAffectedByWithOldState;
120766
120791
  function updateSignatureOfFile(state, signature, path) {
@@ -120771,7 +120796,7 @@ var ts;
120771
120796
  /**
120772
120797
  * Returns if the shape of the signature has changed since last emit
120773
120798
  */
120774
- function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, useFileVersionAsSignature) {
120799
+ function updateShapeSignature(state, programOfThisState, sourceFile, cancellationToken, computeHash, getCanonicalFileName, useFileVersionAsSignature) {
120775
120800
  var _a;
120776
120801
  if (useFileVersionAsSignature === void 0) { useFileVersionAsSignature = state.useFileVersionAsSignature; }
120777
120802
  // If we have cached the result for this file, that means hence forth we should assume file shape is uptodate
@@ -120781,18 +120806,16 @@ var ts;
120781
120806
  var prevSignature = info.signature;
120782
120807
  var latestSignature;
120783
120808
  if (!sourceFile.isDeclarationFile && !useFileVersionAsSignature) {
120784
- var emitOutput_1 = getFileEmitOutput(programOfThisState, sourceFile,
120785
- /*emitOnlyDtsFiles*/ true, cancellationToken,
120786
- /*customTransformers*/ undefined,
120787
- /*forceDtsEmit*/ true);
120788
- var firstDts_1 = ts.firstOrUndefined(emitOutput_1.outputFiles);
120789
- if (firstDts_1) {
120790
- ts.Debug.assert(ts.isDeclarationFileName(firstDts_1.name), "File extension for signature expected to be dts", function () { return "Found: " + ts.getAnyExtensionFromPath(firstDts_1.name) + " for " + firstDts_1.name + ":: All output files: " + JSON.stringify(emitOutput_1.outputFiles.map(function (f) { return f.name; })); });
120791
- latestSignature = computeSignature(firstDts_1.text, computeHash);
120809
+ programOfThisState.emit(sourceFile, function (fileName, text, _writeByteOrderMark, _onError, sourceFiles, data) {
120810
+ ts.Debug.assert(ts.isDeclarationFileName(fileName), "File extension for signature expected to be dts: Got:: " + fileName);
120811
+ latestSignature = ts.computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data);
120792
120812
  if (latestSignature !== prevSignature) {
120793
- updateExportedModules(state, sourceFile, emitOutput_1.exportedModulesFromDeclarationEmit);
120813
+ updateExportedModules(state, sourceFile, sourceFiles[0].exportedModulesFromDeclarationEmit);
120794
120814
  }
120795
- }
120815
+ }, cancellationToken,
120816
+ /*emitOnlyDtsFiles*/ true,
120817
+ /*customTransformers*/ undefined,
120818
+ /*forceDtsEmit*/ true);
120796
120819
  }
120797
120820
  // Default is to use file version as signature
120798
120821
  if (latestSignature === undefined) {
@@ -120815,10 +120838,6 @@ var ts;
120815
120838
  return latestSignature !== prevSignature;
120816
120839
  }
120817
120840
  BuilderState.updateShapeSignature = updateShapeSignature;
120818
- function computeSignature(text, computeHash) {
120819
- return (computeHash || ts.generateDjb2Hash)(text);
120820
- }
120821
- BuilderState.computeSignature = computeSignature;
120822
120841
  /**
120823
120842
  * Coverts the declaration emit result into exported modules map
120824
120843
  */
@@ -120968,7 +120987,7 @@ var ts;
120968
120987
  /**
120969
120988
  * When program emits modular code, gets the files affected by the sourceFile whose shape has changed
120970
120989
  */
120971
- function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash) {
120990
+ function getFilesAffectedByUpdatedShapeWhenModuleEmit(state, programOfThisState, sourceFileWithUpdatedShape, cancellationToken, computeHash, getCanonicalFileName) {
120972
120991
  if (isFileAffectingGlobalScope(sourceFileWithUpdatedShape)) {
120973
120992
  return getAllFilesExcludingDefaultLibraryFile(state, programOfThisState, sourceFileWithUpdatedShape);
120974
120993
  }
@@ -120988,7 +121007,7 @@ var ts;
120988
121007
  if (!seenFileNamesMap.has(currentPath)) {
120989
121008
  var currentSourceFile = programOfThisState.getSourceFileByPath(currentPath);
120990
121009
  seenFileNamesMap.set(currentPath, currentSourceFile);
120991
- if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash)) {
121010
+ if (currentSourceFile && updateShapeSignature(state, programOfThisState, currentSourceFile, cancellationToken, computeHash, getCanonicalFileName)) {
120992
121011
  queue.push.apply(queue, getReferencedByPaths(state, currentSourceFile.resolvedPath));
120993
121012
  }
120994
121013
  }
@@ -121182,7 +121201,7 @@ var ts;
121182
121201
  * This is to allow the callers to be able to actually remove affected file only when the operation is complete
121183
121202
  * eg. if during diagnostics check cancellation token ends up cancelling the request, the affected file should be retained
121184
121203
  */
121185
- function getNextAffectedFile(state, cancellationToken, computeHash, host) {
121204
+ function getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host) {
121186
121205
  var _a, _b;
121187
121206
  while (true) {
121188
121207
  var affectedFiles = state.affectedFiles;
@@ -121194,7 +121213,7 @@ var ts;
121194
121213
  if (!seenAffectedFiles.has(affectedFile.resolvedPath)) {
121195
121214
  // Set the next affected file as seen and remove the cached semantic diagnostics
121196
121215
  state.affectedFilesIndex = affectedFilesIndex;
121197
- handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121216
+ handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121198
121217
  return affectedFile;
121199
121218
  }
121200
121219
  affectedFilesIndex++;
@@ -121222,7 +121241,7 @@ var ts;
121222
121241
  return program;
121223
121242
  }
121224
121243
  // Get next batch of affected files
121225
- state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash);
121244
+ state.affectedFiles = ts.BuilderState.getFilesAffectedByWithOldState(state, program, nextKey.value, cancellationToken, computeHash, getCanonicalFileName);
121226
121245
  state.currentChangedFilePath = nextKey.value;
121227
121246
  state.affectedFilesIndex = 0;
121228
121247
  if (!state.seenAffectedFiles)
@@ -121273,7 +121292,7 @@ var ts;
121273
121292
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
121274
121293
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
121275
121294
  */
121276
- function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121295
+ function handleDtsMayChangeOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121277
121296
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
121278
121297
  // If affected files is everything except default library, then nothing more to do
121279
121298
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
@@ -121281,18 +121300,18 @@ var ts;
121281
121300
  // When a change affects the global scope, all files are considered to be affected without updating their signature
121282
121301
  // That means when affected file is handled, its signature can be out of date
121283
121302
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
121284
- ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash);
121303
+ ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, cancellationToken, computeHash, getCanonicalFileName);
121285
121304
  return;
121286
121305
  }
121287
121306
  if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
121288
121307
  return;
121289
- handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
121308
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host);
121290
121309
  }
121291
121310
  /**
121292
121311
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
121293
121312
  * Also we need to make sure signature is updated for these files
121294
121313
  */
121295
- function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host) {
121314
+ function handleDtsMayChangeOf(state, path, cancellationToken, computeHash, getCanonicalFileName, host) {
121296
121315
  removeSemanticDiagnosticsOf(state, path);
121297
121316
  if (!state.changedFilesSet.has(path)) {
121298
121317
  var program = ts.Debug.checkDefined(state.program);
@@ -121303,7 +121322,7 @@ var ts;
121303
121322
  // This ensures that we dont later during incremental builds considering wrong signature.
121304
121323
  // Eg where this also is needed to ensure that .tsbuildinfo generated by incremental build should be same as if it was first fresh build
121305
121324
  // But we avoid expensive full shape computation, as using file version as shape is enough for correctness.
121306
- ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, !host.disableUseFileVersionAsSignature);
121325
+ ts.BuilderState.updateShapeSignature(state, program, sourceFile, cancellationToken, computeHash, getCanonicalFileName, !host.disableUseFileVersionAsSignature);
121307
121326
  // If not dts emit, nothing more to do
121308
121327
  if (ts.getEmitDeclarations(state.compilerOptions)) {
121309
121328
  addToAffectedFilesPendingEmit(state, path, 0 /* DtsOnly */);
@@ -121328,20 +121347,20 @@ var ts;
121328
121347
  var newSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
121329
121348
  return newSignature !== oldSignature;
121330
121349
  }
121331
- function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
121350
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host) {
121332
121351
  var _a;
121333
121352
  if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
121334
121353
  return false;
121335
121354
  // Every file needs to be handled
121336
121355
  ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
121337
- .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
121356
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, getCanonicalFileName, host); });
121338
121357
  removeDiagnosticsOfLibraryFiles(state);
121339
121358
  return true;
121340
121359
  }
121341
121360
  /**
121342
121361
  * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
121343
121362
  */
121344
- function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
121363
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121345
121364
  var _a;
121346
121365
  // If there was change in signature (dts output) for the changed file,
121347
121366
  // then only we need to handle pending file emit
@@ -121359,9 +121378,9 @@ var ts;
121359
121378
  var currentPath = queue.pop();
121360
121379
  if (!seenFileNamesMap.has(currentPath)) {
121361
121380
  seenFileNamesMap.set(currentPath, true);
121362
- if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
121381
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host))
121363
121382
  return;
121364
- handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
121383
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, getCanonicalFileName, host);
121365
121384
  if (isChangedSignature(state, currentPath)) {
121366
121385
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
121367
121386
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -121373,11 +121392,11 @@ var ts;
121373
121392
  // Go through exported modules from cache first
121374
121393
  // If exported modules has path, all files referencing file exported from are affected
121375
121394
  (_a = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121376
- if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
121395
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, getCanonicalFileName, host))
121377
121396
  return true;
121378
121397
  var references = state.referencedMap.getKeys(exportedFromPath);
121379
121398
  return references && ts.forEachKey(references, function (filePath) {
121380
- return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121399
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121381
121400
  });
121382
121401
  });
121383
121402
  }
@@ -121385,22 +121404,22 @@ var ts;
121385
121404
  * handle dts and semantic diagnostics on file and iterate on anything that exports this file
121386
121405
  * return true when all work is done and we can exit handling dts emit and semantic diagnostics
121387
121406
  */
121388
- function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
121407
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host) {
121389
121408
  var _a, _b;
121390
121409
  if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
121391
121410
  return undefined;
121392
- if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
121411
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host))
121393
121412
  return true;
121394
- handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
121413
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, getCanonicalFileName, host);
121395
121414
  // If exported modules has path, all files referencing file exported from are affected
121396
121415
  (_a = state.exportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
121397
- return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
121416
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, getCanonicalFileName, host);
121398
121417
  });
121399
121418
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
121400
121419
  (_b = state.referencedMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (referencingFilePath) {
121401
121420
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
121402
121421
  handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
121403
- state, referencingFilePath, cancellationToken, computeHash, host);
121422
+ state, referencingFilePath, cancellationToken, computeHash, getCanonicalFileName, host);
121404
121423
  });
121405
121424
  return undefined;
121406
121425
  }
@@ -121719,8 +121738,39 @@ var ts;
121719
121738
  return { host: host, newProgram: newProgram, oldProgram: oldProgram, configFileParsingDiagnostics: configFileParsingDiagnostics || ts.emptyArray };
121720
121739
  }
121721
121740
  ts.getBuilderCreationParameters = getBuilderCreationParameters;
121722
- function computeSignature(text, data, computeHash) {
121723
- return ts.BuilderState.computeSignature((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text, computeHash);
121741
+ function getTextHandlingSourceMapForSignature(text, data) {
121742
+ return (data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text;
121743
+ }
121744
+ function computeSignatureWithDiagnostics(sourceFile, text, computeHash, getCanonicalFileName, data) {
121745
+ var _a;
121746
+ text = getTextHandlingSourceMapForSignature(text, data);
121747
+ var sourceFileDirectory;
121748
+ if ((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length) {
121749
+ text += data.diagnostics.map(function (diagnostic) {
121750
+ return "" + locationInfo(diagnostic) + ts.DiagnosticCategory[diagnostic.category] + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText);
121751
+ }).join("\n");
121752
+ }
121753
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(text);
121754
+ function flattenDiagnosticMessageText(diagnostic) {
121755
+ return ts.isString(diagnostic) ?
121756
+ diagnostic :
121757
+ diagnostic === undefined ?
121758
+ "" :
121759
+ !diagnostic.next ?
121760
+ diagnostic.messageText :
121761
+ diagnostic.messageText + diagnostic.next.map(flattenDiagnosticMessageText).join("\n");
121762
+ }
121763
+ function locationInfo(diagnostic) {
121764
+ if (diagnostic.file.resolvedPath === sourceFile.resolvedPath)
121765
+ return "(" + diagnostic.start + "," + diagnostic.length + ")";
121766
+ if (sourceFileDirectory === undefined)
121767
+ sourceFileDirectory = ts.getDirectoryPath(sourceFile.resolvedPath);
121768
+ return ts.ensurePathIsNonModuleName(ts.getRelativePathFromDirectory(sourceFileDirectory, diagnostic.file.resolvedPath, getCanonicalFileName)) + "(" + diagnostic.start + "," + diagnostic.length + ")";
121769
+ }
121770
+ }
121771
+ ts.computeSignatureWithDiagnostics = computeSignatureWithDiagnostics;
121772
+ function computeSignature(text, computeHash, data) {
121773
+ return (computeHash !== null && computeHash !== void 0 ? computeHash : ts.generateDjb2Hash)(getTextHandlingSourceMapForSignature(text, data));
121724
121774
  }
121725
121775
  ts.computeSignature = computeSignature;
121726
121776
  function createBuilderProgram(kind, _a) {
@@ -121781,7 +121831,7 @@ var ts;
121781
121831
  * in that order would be used to write the files
121782
121832
  */
121783
121833
  function emitNextAffectedFile(writeFile, cancellationToken, emitOnlyDtsFiles, customTransformers) {
121784
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
121834
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
121785
121835
  var emitKind = 1 /* Full */;
121786
121836
  var isPendingEmitFile = false;
121787
121837
  if (!affected) {
@@ -121818,32 +121868,35 @@ var ts;
121818
121868
  }
121819
121869
  function getWriteFileCallback(writeFile, customTransformers) {
121820
121870
  return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
121821
- var _a, _b, _c;
121871
+ var _a, _b, _c, _d, _e, _f, _g;
121822
121872
  if (ts.isDeclarationFileName(fileName)) {
121823
121873
  if (!ts.outFile(state.compilerOptions)) {
121824
121874
  ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
121825
- var newSignature = void 0;
121875
+ var emitSignature = void 0;
121826
121876
  if (!customTransformers) {
121827
121877
  var file = sourceFiles[0];
121828
121878
  var info = state.fileInfos.get(file.resolvedPath);
121829
121879
  if (info.signature === file.version) {
121830
- newSignature = computeSignature(text, data, computeHash);
121831
- if (newSignature !== file.version) { // Update it
121880
+ var signature = computeSignatureWithDiagnostics(file, text, computeHash, getCanonicalFileName, data);
121881
+ // 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
121882
+ if (!((_a = data === null || data === void 0 ? void 0 : data.diagnostics) === null || _a === void 0 ? void 0 : _a.length))
121883
+ emitSignature = signature;
121884
+ if (signature !== file.version) { // Update it
121832
121885
  if (host.storeFilesChangingSignatureDuringEmit)
121833
- (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121886
+ ((_b = state.filesChangingSignature) !== null && _b !== void 0 ? _b : (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
121834
121887
  if (state.exportedModulesMap)
121835
121888
  ts.BuilderState.updateExportedModules(state, file, file.exportedModulesFromDeclarationEmit);
121836
121889
  if (state.affectedFiles) {
121837
121890
  // Keep old signature so we know what to undo if cancellation happens
121838
- var existing = (_a = state.oldSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath);
121891
+ var existing = (_c = state.oldSignatures) === null || _c === void 0 ? void 0 : _c.get(file.resolvedPath);
121839
121892
  if (existing === undefined)
121840
- (state.oldSignatures || (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121841
- info.signature = newSignature;
121893
+ ((_d = state.oldSignatures) !== null && _d !== void 0 ? _d : (state.oldSignatures = new ts.Map())).set(file.resolvedPath, info.signature || false);
121894
+ info.signature = signature;
121842
121895
  }
121843
121896
  else {
121844
121897
  // These are directly commited
121845
- info.signature = newSignature;
121846
- (_b = state.oldExportedModulesMap) === null || _b === void 0 ? void 0 : _b.clear();
121898
+ info.signature = signature;
121899
+ (_e = state.oldExportedModulesMap) === null || _e === void 0 ? void 0 : _e.clear();
121847
121900
  }
121848
121901
  }
121849
121902
  }
@@ -121853,16 +121906,16 @@ var ts;
121853
121906
  // and would need their d.ts change time in --build mode
121854
121907
  if (state.compilerOptions.composite) {
121855
121908
  var filePath = sourceFiles[0].resolvedPath;
121856
- var oldSignature = (_c = state.emitSignatures) === null || _c === void 0 ? void 0 : _c.get(filePath);
121857
- newSignature || (newSignature = computeSignature(text, data, computeHash));
121858
- if (newSignature !== oldSignature) {
121859
- (state.emitSignatures || (state.emitSignatures = new ts.Map())).set(filePath, newSignature);
121909
+ var oldSignature = (_f = state.emitSignatures) === null || _f === void 0 ? void 0 : _f.get(filePath);
121910
+ emitSignature !== null && emitSignature !== void 0 ? emitSignature : (emitSignature = computeSignature(text, computeHash, data));
121911
+ if (emitSignature !== oldSignature) {
121912
+ ((_g = state.emitSignatures) !== null && _g !== void 0 ? _g : (state.emitSignatures = new ts.Map())).set(filePath, emitSignature);
121860
121913
  state.hasChangedEmitSignature = true;
121861
121914
  }
121862
121915
  }
121863
121916
  }
121864
121917
  else if (state.compilerOptions.composite) {
121865
- var newSignature = computeSignature(text, data, computeHash);
121918
+ var newSignature = computeSignature(text, computeHash, data);
121866
121919
  if (newSignature !== state.outSignature) {
121867
121920
  state.outSignature = newSignature;
121868
121921
  state.hasChangedEmitSignature = true;
@@ -121942,7 +121995,7 @@ var ts;
121942
121995
  */
121943
121996
  function getSemanticDiagnosticsOfNextAffectedFile(cancellationToken, ignoreSourceFile) {
121944
121997
  while (true) {
121945
- var affected = getNextAffectedFile(state, cancellationToken, computeHash, host);
121998
+ var affected = getNextAffectedFile(state, cancellationToken, computeHash, getCanonicalFileName, host);
121946
121999
  if (!affected) {
121947
122000
  // Done
121948
122001
  return undefined;
@@ -128388,12 +128441,18 @@ var ts;
128388
128441
  // flag causes us to return the first node whose end position matches the position and which produces and acceptable token
128389
128442
  // kind. Meanwhile, if includePrecedingTokenAtEndPosition is unset, we look for the first node whose start is <= the
128390
128443
  // position and whose end is greater than the position.
128444
+ // There are more sophisticated end tests later, but this one is very fast
128445
+ // and allows us to skip a bunch of work
128446
+ var end = children[middle].getEnd();
128447
+ if (end < position) {
128448
+ return -1 /* LessThan */;
128449
+ }
128391
128450
  var start = allowPositionInLeadingTrivia ? children[middle].getFullStart() : children[middle].getStart(sourceFile, /*includeJsDoc*/ true);
128392
128451
  if (start > position) {
128393
128452
  return 1 /* GreaterThan */;
128394
128453
  }
128395
128454
  // first element whose start position is before the input and whose end position is after or equal to the input
128396
- if (nodeContainsPosition(children[middle])) {
128455
+ if (nodeContainsPosition(children[middle], start, end)) {
128397
128456
  if (children[middle - 1]) {
128398
128457
  // we want the _first_ element that contains the position, so left-recur if the prior node also contains the position
128399
128458
  if (nodeContainsPosition(children[middle - 1])) {
@@ -128425,13 +128484,16 @@ var ts;
128425
128484
  case "continue-outer": continue outer;
128426
128485
  }
128427
128486
  }
128428
- function nodeContainsPosition(node) {
128429
- var start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true);
128487
+ function nodeContainsPosition(node, start, end) {
128488
+ end !== null && end !== void 0 ? end : (end = node.getEnd());
128489
+ if (end < position) {
128490
+ return false;
128491
+ }
128492
+ start !== null && start !== void 0 ? start : (start = allowPositionInLeadingTrivia ? node.getFullStart() : node.getStart(sourceFile, /*includeJsDoc*/ true));
128430
128493
  if (start > position) {
128431
128494
  // If this child begins after position, then all subsequent children will as well.
128432
128495
  return false;
128433
128496
  }
128434
- var end = node.getEnd();
128435
128497
  if (position < end || (position === end && (node.kind === 1 /* EndOfFileToken */ || includeEndPosition))) {
128436
128498
  return true;
128437
128499
  }
@@ -133328,37 +133390,36 @@ var ts;
133328
133390
  }
133329
133391
  }
133330
133392
  var entries = ts.createSortedArray();
133331
- if (isUncheckedFile(sourceFile, compilerOptions)) {
133332
- var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
133333
- /*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);
133334
- getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
133335
- }
133336
- else {
133337
- if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
133338
- return undefined;
133339
- }
133340
- getCompletionEntriesFromSymbols(symbols, entries,
133341
- /*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);
133393
+ var isChecked = isCheckedFile(sourceFile, compilerOptions);
133394
+ if (isChecked && !isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
133395
+ return undefined;
133342
133396
  }
133397
+ var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
133398
+ /*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);
133343
133399
  if (keywordFilters !== 0 /* None */) {
133344
- var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
133345
133400
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
133346
133401
  var keywordEntry = _a[_i];
133347
- if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !entryNames_1.has(keywordEntry.name)) {
133402
+ if (isTypeOnlyLocation && ts.isTypeKeyword(ts.stringToToken(keywordEntry.name)) || !uniqueNames.has(keywordEntry.name)) {
133403
+ uniqueNames.add(keywordEntry.name);
133348
133404
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133349
133405
  }
133350
133406
  }
133351
133407
  }
133352
- var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
133353
133408
  for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
133354
133409
  var keywordEntry = _c[_b];
133355
- if (!entryNames.has(keywordEntry.name)) {
133410
+ if (!uniqueNames.has(keywordEntry.name)) {
133411
+ uniqueNames.add(keywordEntry.name);
133356
133412
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133357
133413
  }
133358
133414
  }
133359
133415
  for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
133360
133416
  var literal = literals_1[_d];
133361
- ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
133417
+ var literalEntry = createCompletionEntryForLiteral(sourceFile, preferences, literal);
133418
+ uniqueNames.add(literalEntry.name);
133419
+ ts.insertSorted(entries, literalEntry, compareCompletionEntries, /*allowDuplicates*/ true);
133420
+ }
133421
+ if (!isChecked) {
133422
+ getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
133362
133423
  }
133363
133424
  return {
133364
133425
  flags: completionData.flags,
@@ -133370,8 +133431,8 @@ var ts;
133370
133431
  entries: entries,
133371
133432
  };
133372
133433
  }
133373
- function isUncheckedFile(sourceFile, compilerOptions) {
133374
- return ts.isSourceFileJS(sourceFile) && !ts.isCheckJsEnabledForFile(sourceFile, compilerOptions);
133434
+ function isCheckedFile(sourceFile, compilerOptions) {
133435
+ return !ts.isSourceFileJS(sourceFile) || !!ts.isCheckJsEnabledForFile(sourceFile, compilerOptions);
133375
133436
  }
133376
133437
  function isMemberCompletionKind(kind) {
133377
133438
  switch (kind) {
@@ -134329,7 +134390,7 @@ var ts;
134329
134390
  }
134330
134391
  function getCompletionData(program, log, sourceFile, compilerOptions, position, preferences, detailsEntryId, host, formatContext, cancellationToken) {
134331
134392
  var typeChecker = program.getTypeChecker();
134332
- var inUncheckedFile = isUncheckedFile(sourceFile, compilerOptions);
134393
+ var inCheckedFile = isCheckedFile(sourceFile, compilerOptions);
134333
134394
  var start = ts.timestamp();
134334
134395
  var currentToken = ts.getTokenAtPosition(sourceFile, position); // TODO: GH#15853
134335
134396
  // We will check for jsdoc comments with insideComment and getJsDocTagAtPosition. (TODO: that seems rather inefficient to check the same thing so many times.)
@@ -134745,15 +134806,7 @@ var ts;
134745
134806
  isNewIdentifierLocation = true;
134746
134807
  }
134747
134808
  var propertyAccess = node.kind === 200 /* ImportType */ ? node : node.parent;
134748
- if (inUncheckedFile) {
134749
- // In javascript files, for union types, we don't just get the members that
134750
- // the individual types have in common, we also include all the members that
134751
- // each individual type has. This is because we're going to add all identifiers
134752
- // anyways. So we might as well elevate the members that were at least part
134753
- // of the individual types to a higher status since we know what they are.
134754
- symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); }));
134755
- }
134756
- else {
134809
+ if (inCheckedFile) {
134757
134810
  for (var _i = 0, _a = type.getApparentProperties(); _i < _a.length; _i++) {
134758
134811
  var symbol = _a[_i];
134759
134812
  if (typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, symbol)) {
@@ -134761,6 +134814,14 @@ var ts;
134761
134814
  }
134762
134815
  }
134763
134816
  }
134817
+ else {
134818
+ // In javascript files, for union types, we don't just get the members that
134819
+ // the individual types have in common, we also include all the members that
134820
+ // each individual type has. This is because we're going to add all identifiers
134821
+ // anyways. So we might as well elevate the members that were at least part
134822
+ // of the individual types to a higher status since we know what they are.
134823
+ symbols.push.apply(symbols, ts.filter(getPropertiesForCompletion(type, typeChecker), function (s) { return typeChecker.isValidPropertyAccessForCompletions(propertyAccess, type, s); }));
134824
+ }
134764
134825
  if (insertAwait && preferences.includeCompletionsWithInsertText) {
134765
134826
  var promiseType = typeChecker.getPromisedTypeOfPromise(type);
134766
134827
  if (promiseType) {
@@ -155123,7 +155184,7 @@ var ts;
155123
155184
  if (!newConstraint)
155124
155185
  return;
155125
155186
  var newConstraintText = newConstraint[1];
155126
- changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
155187
+ changes.insertText(related.file, decl.name.end, " extends " + newConstraintText);
155127
155188
  }
155128
155189
  function findAncestorMatchingSpan(sourceFile, span) {
155129
155190
  var token = ts.getTokenAtPosition(sourceFile, span.start);
@@ -171067,7 +171128,7 @@ var ts;
171067
171128
  }
171068
171129
  server.updateProjectIfDirty(this);
171069
171130
  this.builderState = ts.BuilderState.create(this.program, this.projectService.toCanonicalFileName, this.builderState, /*disableUseFileVersionAsSignature*/ true);
171070
- return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, ts.maybeBind(this.projectService.host, this.projectService.host.createHash)), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; });
171131
+ return ts.mapDefined(ts.BuilderState.getFilesAffectedBy(this.builderState, this.program, scriptInfo.path, this.cancellationToken, ts.maybeBind(this.projectService.host, this.projectService.host.createHash), this.getCanonicalFileName), function (sourceFile) { return _this.shouldEmitFile(_this.projectService.getScriptInfoForPath(sourceFile.path)) ? sourceFile.fileName : undefined; });
171071
171132
  };
171072
171133
  /**
171073
171134
  * Returns true if emit was conducted