@typescript-deploys/pr-build 4.7.0-pr-48792-4 → 4.7.0-pr-47461-10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-insiders.20220420";
297
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220425";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -14896,7 +14896,7 @@ var ts;
14896
14896
  var _a;
14897
14897
  // If we don't need to downlevel and we can reach the original source text using
14898
14898
  // the node's parent reference, then simply get the text as it was originally written.
14899
- if (canUseOriginalText(node, flags)) {
14899
+ if (sourceFile && canUseOriginalText(node, flags)) {
14900
14900
  return getSourceTextOfNodeFromSourceFile(sourceFile, node);
14901
14901
  }
14902
14902
  // If we can't reach the original source text, use the canonical form if it's a number,
@@ -17501,11 +17501,19 @@ var ts;
17501
17501
  return !!name && isDynamicName(name);
17502
17502
  }
17503
17503
  ts.hasDynamicName = hasDynamicName;
17504
+ function getComputedPropertyNameExpression(name) {
17505
+ return ts.isElementAccessExpression(name.expression)
17506
+ ? skipParentheses(name.expression.argumentExpression)
17507
+ : name.expression;
17508
+ }
17509
+ ts.getComputedPropertyNameExpression = getComputedPropertyNameExpression;
17504
17510
  function isDynamicName(name) {
17505
17511
  if (!(name.kind === 162 /* ComputedPropertyName */ || name.kind === 207 /* ElementAccessExpression */)) {
17506
17512
  return false;
17507
17513
  }
17508
- var expr = ts.isElementAccessExpression(name) ? skipParentheses(name.argumentExpression) : name.expression;
17514
+ var expr = ts.isElementAccessExpression(name)
17515
+ ? skipParentheses(name.argumentExpression)
17516
+ : getComputedPropertyNameExpression(name);
17509
17517
  return !isStringOrNumericLiteralLike(expr) &&
17510
17518
  !isSignedNumericLiteral(expr);
17511
17519
  }
@@ -17519,7 +17527,7 @@ var ts;
17519
17527
  case 8 /* NumericLiteral */:
17520
17528
  return ts.escapeLeadingUnderscores(name.text);
17521
17529
  case 162 /* ComputedPropertyName */:
17522
- var nameExpression = name.expression;
17530
+ var nameExpression = getComputedPropertyNameExpression(name);
17523
17531
  if (isStringOrNumericLiteralLike(nameExpression)) {
17524
17532
  return ts.escapeLeadingUnderscores(nameExpression.text);
17525
17533
  }
@@ -18487,10 +18495,10 @@ var ts;
18487
18495
  return ts.combinePaths(newDirPath, sourceFilePath);
18488
18496
  }
18489
18497
  ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
18490
- function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
18491
- host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
18498
+ function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
18499
+ host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
18492
18500
  diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
18493
- }, sourceFiles);
18501
+ }, sourceFiles, data);
18494
18502
  }
18495
18503
  ts.writeFile = writeFile;
18496
18504
  function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
@@ -34417,7 +34425,7 @@ var ts;
34417
34425
  return makeBinaryExpression(expr, parseTokenNode(), parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction), pos);
34418
34426
  }
34419
34427
  // It wasn't an assignment or a lambda. This is a conditional expression:
34420
- return parseConditionalExpressionRest(expr, pos, disallowReturnTypeInArrowFunction);
34428
+ return parseConditionalExpressionRest(expr, pos);
34421
34429
  }
34422
34430
  function isYieldExpression() {
34423
34431
  if (token() === 125 /* YieldKeyword */) {
@@ -34482,7 +34490,7 @@ var ts;
34482
34490
  return addJSDocComment(finishNode(node, pos));
34483
34491
  }
34484
34492
  function tryParseParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) {
34485
- var triState = isParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction);
34493
+ var triState = isParenthesizedArrowFunctionExpression();
34486
34494
  if (triState === 0 /* False */) {
34487
34495
  // It's definitely not a parenthesized arrow function expression.
34488
34496
  return undefined;
@@ -34492,16 +34500,16 @@ var ts;
34492
34500
  // it out, but don't allow any ambiguity, and return 'undefined' if this could be an
34493
34501
  // expression instead.
34494
34502
  return triState === 1 /* True */ ?
34495
- parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, disallowReturnTypeInArrowFunction) :
34503
+ parseParenthesizedArrowFunctionExpression(/*allowAmbiguity*/ true, /*disallowReturnTypeInArrowFunction*/ false) :
34496
34504
  tryParse(function () { return parsePossibleParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction); });
34497
34505
  }
34498
34506
  // True -> We definitely expect a parenthesized arrow function here.
34499
34507
  // False -> There *cannot* be a parenthesized arrow function here.
34500
34508
  // Unknown -> There *might* be a parenthesized arrow function here.
34501
34509
  // Speculatively look ahead to be sure, and rollback if not.
34502
- function isParenthesizedArrowFunctionExpression(disallowReturnTypeInArrowFunction) {
34510
+ function isParenthesizedArrowFunctionExpression() {
34503
34511
  if (token() === 20 /* OpenParenToken */ || token() === 29 /* LessThanToken */ || token() === 131 /* AsyncKeyword */) {
34504
- return lookAhead(function () { return isParenthesizedArrowFunctionExpressionWorker(disallowReturnTypeInArrowFunction); });
34512
+ return lookAhead(isParenthesizedArrowFunctionExpressionWorker);
34505
34513
  }
34506
34514
  if (token() === 38 /* EqualsGreaterThanToken */) {
34507
34515
  // ERROR RECOVERY TWEAK:
@@ -34512,7 +34520,7 @@ var ts;
34512
34520
  // Definitely not a parenthesized arrow function.
34513
34521
  return 0 /* False */;
34514
34522
  }
34515
- function isParenthesizedArrowFunctionExpressionWorker(disallowReturnTypeInArrowFunction) {
34523
+ function isParenthesizedArrowFunctionExpressionWorker() {
34516
34524
  if (token() === 131 /* AsyncKeyword */) {
34517
34525
  nextToken();
34518
34526
  if (scanner.hasPrecedingLineBreak()) {
@@ -34532,13 +34540,8 @@ var ts;
34532
34540
  // but this is probably what the user intended.
34533
34541
  var third = nextToken();
34534
34542
  switch (third) {
34535
- case 58 /* ColonToken */:
34536
- if (disallowReturnTypeInArrowFunction) {
34537
- // "a ? () : ..."
34538
- return 0 /* False */;
34539
- }
34540
- return 1 /* True */;
34541
34543
  case 38 /* EqualsGreaterThanToken */:
34544
+ case 58 /* ColonToken */:
34542
34545
  case 18 /* OpenBraceToken */:
34543
34546
  return 1 /* True */;
34544
34547
  default:
@@ -34712,8 +34715,13 @@ var ts;
34712
34715
  // This is a valid arrow function with "z" as the return type.
34713
34716
  //
34714
34717
  // But, if we're in the true side of a conditional expression, this colon
34715
- // terminates the expression, so we cannot allow a return type, even if we aren't
34718
+ // terminates the expression, so we cannot allow a return type if we aren't
34716
34719
  // certain whether or not the preceding text was parsed as a parameter list.
34720
+ //
34721
+ // For example,
34722
+ // a() ? (b: number, c?: string): void => d() : e
34723
+ // is determined by isParenthesizedArrowFunctionExpression to unambiguously
34724
+ // be an arrow expression, so we allow a return type.
34717
34725
  if (disallowReturnTypeInArrowFunction && token() === 58 /* ColonToken */) {
34718
34726
  return undefined;
34719
34727
  }
@@ -34783,7 +34791,7 @@ var ts;
34783
34791
  topLevel = savedTopLevel;
34784
34792
  return node;
34785
34793
  }
34786
- function parseConditionalExpressionRest(leftOperand, pos, disallowReturnTypeInArrowFunction) {
34794
+ function parseConditionalExpressionRest(leftOperand, pos) {
34787
34795
  // Note: we are passed in an expression which was produced from parseBinaryExpressionOrHigher.
34788
34796
  var questionToken = parseOptionalToken(57 /* QuestionToken */);
34789
34797
  if (!questionToken) {
@@ -34793,7 +34801,7 @@ var ts;
34793
34801
  // we do not that for the 'whenFalse' part.
34794
34802
  var colonToken;
34795
34803
  return finishNode(factory.createConditionalExpression(leftOperand, questionToken, doOutsideOfContext(disallowInAndDecoratorContext, function () { return parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true); }), colonToken = parseExpectedToken(58 /* ColonToken */), ts.nodeIsPresent(colonToken)
34796
- ? parseAssignmentExpressionOrHigher(disallowReturnTypeInArrowFunction) // inherit disallowReturnTypeInArrowFunction in false side
34804
+ ? parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ true)
34797
34805
  : createMissingNode(79 /* Identifier */, /*reportAtCurrentPosition*/ false, ts.Diagnostics._0_expected, ts.tokenToString(58 /* ColonToken */))), pos);
34798
34806
  }
34799
34807
  function parseBinaryExpressionOrHigher(precedence) {
@@ -44641,7 +44649,7 @@ var ts;
44641
44649
  return (ts.isGlobalScopeAugmentation(node) ? "__global" : "\"" + moduleName + "\"");
44642
44650
  }
44643
44651
  if (name.kind === 162 /* ComputedPropertyName */) {
44644
- var nameExpression = name.expression;
44652
+ var nameExpression = ts.getComputedPropertyNameExpression(name);
44645
44653
  // treat computed property names where expression is string/numeric literal as just string/numeric literal
44646
44654
  if (ts.isStringOrNumericLiteralLike(nameExpression)) {
44647
44655
  return ts.escapeLeadingUnderscores(nameExpression.text);
@@ -73626,6 +73634,7 @@ var ts;
73626
73634
  }
73627
73635
  }
73628
73636
  else {
73637
+ error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
73629
73638
  typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
73630
73639
  }
73631
73640
  }
@@ -75863,6 +75872,7 @@ var ts;
75863
75872
  // decorators are applied to a declaration by the emitter, and not to an expression.
75864
75873
  var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75865
75874
  var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
75875
+ argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75866
75876
  // The following variables are captured and modified by calls to chooseOverload.
75867
75877
  // If overload resolution or type argument inference fails, we want to report the
75868
75878
  // best error possible. The best error is one which says that an argument was not
@@ -76078,7 +76088,7 @@ var ts;
76078
76088
  // If one or more context sensitive arguments were excluded, we start including
76079
76089
  // them now (and keeping do so for any subsequent candidates) and perform a second
76080
76090
  // round of type inference and applicability checking for this particular candidate.
76081
- argCheckMode = 0 /* Normal */;
76091
+ argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
76082
76092
  if (inferenceContext) {
76083
76093
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
76084
76094
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -110160,6 +110170,7 @@ var ts;
110160
110170
  else {
110161
110171
  printer.writeFile(sourceFile, writer, sourceMapGenerator);
110162
110172
  }
110173
+ var sourceMapUrlPos;
110163
110174
  if (sourceMapGenerator) {
110164
110175
  if (sourceMapDataList) {
110165
110176
  sourceMapDataList.push({
@@ -110171,6 +110182,7 @@ var ts;
110171
110182
  if (sourceMappingURL) {
110172
110183
  if (!writer.isAtStartOfLine())
110173
110184
  writer.rawWrite(newLine);
110185
+ sourceMapUrlPos = writer.getTextPos();
110174
110186
  writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment
110175
110187
  }
110176
110188
  // Write the source map
@@ -110183,7 +110195,7 @@ var ts;
110183
110195
  writer.writeLine();
110184
110196
  }
110185
110197
  // Write the output file
110186
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
110198
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
110187
110199
  // Reset state
110188
110200
  writer.clear();
110189
110201
  }
@@ -110705,7 +110717,7 @@ var ts;
110705
110717
  setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined);
110706
110718
  }
110707
110719
  function getCurrentLineMap() {
110708
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
110720
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
110709
110721
  }
110710
110722
  function emit(node, parenthesizerRule) {
110711
110723
  if (node === undefined)
@@ -111880,7 +111892,7 @@ var ts;
111880
111892
  increaseIndent();
111881
111893
  }
111882
111894
  var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */;
111883
- var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */;
111895
+ var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */;
111884
111896
  emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine);
111885
111897
  if (indentedFlag) {
111886
111898
  decreaseIndent();
@@ -112236,7 +112248,7 @@ var ts;
112236
112248
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
112237
112249
  // Emit semicolon in non json files
112238
112250
  // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation)
112239
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112251
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112240
112252
  writeTrailingSemicolon();
112241
112253
  }
112242
112254
  }
@@ -112529,7 +112541,7 @@ var ts;
112529
112541
  if (body.multiLine) {
112530
112542
  return false;
112531
112543
  }
112532
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112544
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112533
112545
  return false;
112534
112546
  }
112535
112547
  if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)
@@ -112554,12 +112566,7 @@ var ts;
112554
112566
  var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
112555
112567
  ? emitBlockFunctionBodyOnSingleLine
112556
112568
  : emitBlockFunctionBodyWorker;
112557
- if (emitBodyWithDetachedComments) {
112558
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112559
- }
112560
- else {
112561
- emitBlockFunctionBody(body);
112562
- }
112569
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112563
112570
  decreaseIndent();
112564
112571
  writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body);
112565
112572
  onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
@@ -112956,7 +112963,8 @@ var ts;
112956
112963
  var emitAsSingleStatement = statements.length === 1 &&
112957
112964
  (
112958
112965
  // treat synthesized nodes as located on the same line for emit purposes
112959
- ts.nodeIsSynthesized(parentNode) ||
112966
+ !currentSourceFile ||
112967
+ ts.nodeIsSynthesized(parentNode) ||
112960
112968
  ts.nodeIsSynthesized(statements[0]) ||
112961
112969
  ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
112962
112970
  var format = 163969 /* CaseOrDefaultClauseStatements */;
@@ -113187,16 +113195,14 @@ var ts;
113187
113195
  function emitSourceFile(node) {
113188
113196
  writeLine();
113189
113197
  var statements = node.statements;
113190
- if (emitBodyWithDetachedComments) {
113191
- // Emit detached comment if there are no prologue directives or if the first node is synthesized.
113192
- // The synthesized node will have no leading comment so some comments may be missed.
113193
- var shouldEmitDetachedComment = statements.length === 0 ||
113194
- !ts.isPrologueDirective(statements[0]) ||
113195
- ts.nodeIsSynthesized(statements[0]);
113196
- if (shouldEmitDetachedComment) {
113197
- emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
113198
- return;
113199
- }
113198
+ // Emit detached comment if there are no prologue directives or if the first node is synthesized.
113199
+ // The synthesized node will have no leading comment so some comments may be missed.
113200
+ var shouldEmitDetachedComment = statements.length === 0 ||
113201
+ !ts.isPrologueDirective(statements[0]) ||
113202
+ ts.nodeIsSynthesized(statements[0]);
113203
+ if (shouldEmitDetachedComment) {
113204
+ emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
113205
+ return;
113200
113206
  }
113201
113207
  emitSourceFileWorker(node);
113202
113208
  }
@@ -113585,7 +113591,7 @@ var ts;
113585
113591
  }
113586
113592
  if (isEmpty) {
113587
113593
  // Write a line terminator if the parent node was multi-line
113588
- if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113594
+ if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113589
113595
  writeLine();
113590
113596
  }
113591
113597
  else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) {
@@ -113846,7 +113852,7 @@ var ts;
113846
113852
  }
113847
113853
  var firstChild_1 = children[0];
113848
113854
  if (firstChild_1 === undefined) {
113849
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113855
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113850
113856
  }
113851
113857
  if (firstChild_1.pos === nextListElementPos) {
113852
113858
  // If this child starts at the beginning of a list item in a parent list, its leading
@@ -113870,7 +113876,7 @@ var ts;
113870
113876
  // JsxText will be written with its leading whitespace, so don't add more manually.
113871
113877
  return 0;
113872
113878
  }
113873
- if (parentNode &&
113879
+ if (currentSourceFile && parentNode &&
113874
113880
  !ts.positionIsSynthesized(parentNode.pos) &&
113875
113881
  !ts.nodeIsSynthesized(firstChild_1) &&
113876
113882
  (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -113894,7 +113900,7 @@ var ts;
113894
113900
  // JsxText will be written with its leading whitespace, so don't add more manually.
113895
113901
  return 0;
113896
113902
  }
113897
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113903
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113898
113904
  if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
113899
113905
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
113900
113906
  }
@@ -113926,9 +113932,9 @@ var ts;
113926
113932
  }
113927
113933
  var lastChild = ts.lastOrUndefined(children);
113928
113934
  if (lastChild === undefined) {
113929
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113935
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113930
113936
  }
113931
- if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
113937
+ if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
113932
113938
  if (preserveSourceNewlines) {
113933
113939
  var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
113934
113940
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -114001,7 +114007,7 @@ var ts;
114001
114007
  if (ts.getStartsOnNewLine(node2)) {
114002
114008
  return 1;
114003
114009
  }
114004
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
114010
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
114005
114011
  if (preserveSourceNewlines) {
114006
114012
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
114007
114013
  }
@@ -114011,7 +114017,7 @@ var ts;
114011
114017
  }
114012
114018
  function isEmptyBlock(block) {
114013
114019
  return block.statements.length === 0
114014
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
114020
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
114015
114021
  }
114016
114022
  function skipSynthesizedParentheses(node) {
114017
114023
  while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) {
@@ -114023,16 +114029,23 @@ var ts;
114023
114029
  if (ts.isGeneratedIdentifier(node)) {
114024
114030
  return generateName(node);
114025
114031
  }
114026
- else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
114027
- return ts.idText(node);
114028
- }
114029
- else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
114032
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
114030
114033
  return getTextOfNode(node.textSourceNode, includeTrivia);
114031
114034
  }
114032
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
114033
- return node.text;
114035
+ var sourceFile = currentSourceFile; // const needed for control flow
114036
+ var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
114037
+ if (ts.isMemberName(node)) {
114038
+ if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
114039
+ return ts.idText(node);
114040
+ }
114041
+ }
114042
+ else {
114043
+ ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary
114044
+ if (!canUseSourceFile) {
114045
+ return node.text;
114046
+ }
114034
114047
  }
114035
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
114048
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
114036
114049
  }
114037
114050
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
114038
114051
  if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
@@ -114611,7 +114624,7 @@ var ts;
114611
114624
  return true;
114612
114625
  }
114613
114626
  function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
114614
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114627
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114615
114628
  return;
114616
114629
  if (!hasWrittenComment) {
114617
114630
  ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -114638,7 +114651,7 @@ var ts;
114638
114651
  forEachTrailingCommentToEmit(pos, emitTrailingComment);
114639
114652
  }
114640
114653
  function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114641
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114654
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114642
114655
  return;
114643
114656
  // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
114644
114657
  if (!writer.isAtStartOfLine()) {
@@ -114660,6 +114673,8 @@ var ts;
114660
114673
  exitComment();
114661
114674
  }
114662
114675
  function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
114676
+ if (!currentSourceFile)
114677
+ return;
114663
114678
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114664
114679
  emitPos(commentPos);
114665
114680
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114669,6 +114684,8 @@ var ts;
114669
114684
  }
114670
114685
  }
114671
114686
  function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114687
+ if (!currentSourceFile)
114688
+ return;
114672
114689
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114673
114690
  emitPos(commentPos);
114674
114691
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114701,6 +114718,8 @@ var ts;
114701
114718
  return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
114702
114719
  }
114703
114720
  function forEachLeadingCommentWithoutDetachedComments(cb) {
114721
+ if (!currentSourceFile)
114722
+ return;
114704
114723
  // get the leading comments from detachedPos
114705
114724
  var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
114706
114725
  if (detachedCommentsInfo.length - 1) {
@@ -114712,7 +114731,7 @@ var ts;
114712
114731
  ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos);
114713
114732
  }
114714
114733
  function emitDetachedCommentsAndUpdateCommentsInfo(range) {
114715
- var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
114734
+ var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
114716
114735
  if (currentDetachedCommentInfo) {
114717
114736
  if (detachedCommentsInfo) {
114718
114737
  detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -114723,7 +114742,7 @@ var ts;
114723
114742
  }
114724
114743
  }
114725
114744
  function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
114726
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114745
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114727
114746
  return;
114728
114747
  emitPos(commentPos);
114729
114748
  ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
@@ -114735,7 +114754,7 @@ var ts;
114735
114754
  * @return true if the comment is a triple-slash comment else false
114736
114755
  */
114737
114756
  function isTripleSlashComment(commentPos, commentEnd) {
114738
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114757
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114739
114758
  }
114740
114759
  // Source Maps
114741
114760
  function getParsedSourceMap(node) {
@@ -115650,7 +115669,11 @@ var ts;
115650
115669
  return newValue;
115651
115670
  };
115652
115671
  if (originalWriteFile) {
115653
- host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
115672
+ host.writeFile = function (fileName, data) {
115673
+ var rest = [];
115674
+ for (var _i = 2; _i < arguments.length; _i++) {
115675
+ rest[_i - 2] = arguments[_i];
115676
+ }
115654
115677
  var key = toPath(fileName);
115655
115678
  fileExistsCache.delete(key);
115656
115679
  var value = readFileCache.get(key);
@@ -115664,7 +115687,7 @@ var ts;
115664
115687
  sourceFileCache.delete(key);
115665
115688
  }
115666
115689
  }
115667
- originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
115690
+ originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
115668
115691
  };
115669
115692
  }
115670
115693
  // directoryExists
@@ -116597,6 +116620,7 @@ var ts;
116597
116620
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
116598
116621
  getFileIncludeReasons: function () { return fileReasons; },
116599
116622
  structureIsReused: structureIsReused,
116623
+ writeFile: writeFile,
116600
116624
  };
116601
116625
  onProgramCreateComplete();
116602
116626
  // Add file processingDiagnostics
@@ -117094,7 +117118,7 @@ var ts;
117094
117118
  getProjectReferenceRedirect: getProjectReferenceRedirect,
117095
117119
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
117096
117120
  getSymlinkCache: getSymlinkCache,
117097
- writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
117121
+ writeFile: writeFileCallback || writeFile,
117098
117122
  isEmitBlocked: isEmitBlocked,
117099
117123
  readFile: function (f) { return host.readFile(f); },
117100
117124
  fileExists: function (f) {
@@ -117114,6 +117138,9 @@ var ts;
117114
117138
  getFileIncludeReasons: program.getFileIncludeReasons,
117115
117139
  };
117116
117140
  }
117141
+ function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
117142
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
117143
+ }
117117
117144
  function emitBuildInfo(writeFileCallback) {
117118
117145
  ts.Debug.assert(!ts.outFile(options));
117119
117146
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
@@ -119556,6 +119583,7 @@ var ts;
119556
119583
  }
119557
119584
  }
119558
119585
  }
119586
+ BuilderState.updateExportedModules = updateExportedModules;
119559
119587
  /**
119560
119588
  * Updates the exported modules from cache into state's exported modules map
119561
119589
  * This should be called whenever it is safe to commit the state of the builder
@@ -119979,6 +120007,18 @@ var ts;
119979
120007
  }
119980
120008
  return undefined;
119981
120009
  }
120010
+ function removeDiagnosticsOfLibraryFiles(state) {
120011
+ if (!state.cleanedDiagnosticsOfLibFiles) {
120012
+ state.cleanedDiagnosticsOfLibFiles = true;
120013
+ var program_1 = ts.Debug.checkDefined(state.program);
120014
+ var options_2 = program_1.getCompilerOptions();
120015
+ ts.forEach(program_1.getSourceFiles(), function (f) {
120016
+ return program_1.isSourceFileDefaultLibrary(f) &&
120017
+ !ts.skipTypeChecking(f, options_2, program_1) &&
120018
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
120019
+ });
120020
+ }
120021
+ }
119982
120022
  /**
119983
120023
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119984
120024
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
@@ -119988,28 +120028,17 @@ var ts;
119988
120028
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119989
120029
  // If affected files is everything except default library, then nothing more to do
119990
120030
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
119991
- if (!state.cleanedDiagnosticsOfLibFiles) {
119992
- state.cleanedDiagnosticsOfLibFiles = true;
119993
- var program_1 = ts.Debug.checkDefined(state.program);
119994
- var options_2 = program_1.getCompilerOptions();
119995
- ts.forEach(program_1.getSourceFiles(), function (f) {
119996
- return program_1.isSourceFileDefaultLibrary(f) &&
119997
- !ts.skipTypeChecking(f, options_2, program_1) &&
119998
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
119999
- });
120000
- }
120031
+ removeDiagnosticsOfLibraryFiles(state);
120001
120032
  // When a change affects the global scope, all files are considered to be affected without updating their signature
120002
120033
  // That means when affected file is handled, its signature can be out of date
120003
120034
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
120004
120035
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
120005
120036
  return;
120006
120037
  }
120007
- else {
120008
- ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
120009
- }
120010
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
120011
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
120012
- }
120038
+ ts.Debug.assert(state.hasCalledUpdateShapeSignature.has(affectedFile.resolvedPath) || ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.has(affectedFile.resolvedPath)), "Signature not updated for affected file: " + affectedFile.fileName);
120039
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
120040
+ return;
120041
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
120013
120042
  }
120014
120043
  /**
120015
120044
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
@@ -120051,16 +120080,41 @@ var ts;
120051
120080
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
120052
120081
  return newSignature !== oldSignature;
120053
120082
  }
120083
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
120084
+ // Go through exported modules from cache first
120085
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
120086
+ var result = keys && ts.forEachKey(keys, fn);
120087
+ if (result)
120088
+ return result;
120089
+ // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120090
+ keys = state.exportedModulesMap.getKeys(filePath);
120091
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
120092
+ var _a;
120093
+ // If the cache had an updated value, skip
120094
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120095
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
120096
+ fn(exportedFromPath) :
120097
+ undefined;
120098
+ });
120099
+ }
120100
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
120101
+ var _a;
120102
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
120103
+ return false;
120104
+ // Every file needs to be handled
120105
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
120106
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
120107
+ removeDiagnosticsOfLibraryFiles(state);
120108
+ return true;
120109
+ }
120054
120110
  /**
120055
- * Iterate on referencing modules that export entities from affected file
120111
+ * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
120056
120112
  */
120057
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
120058
- var _a, _b;
120113
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
120059
120114
  // If there was change in signature (dts output) for the changed file,
120060
120115
  // then only we need to handle pending file emit
120061
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
120116
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
120062
120117
  return;
120063
- }
120064
120118
  if (!isChangedSignature(state, affectedFile.resolvedPath))
120065
120119
  return;
120066
120120
  // Since isolated modules dont change js files, files affected by change in signature is itself
@@ -120073,7 +120127,9 @@ var ts;
120073
120127
  var currentPath = queue.pop();
120074
120128
  if (!seenFileNamesMap.has(currentPath)) {
120075
120129
  seenFileNamesMap.set(currentPath, true);
120076
- fn(state, currentPath);
120130
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
120131
+ return;
120132
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
120077
120133
  if (isChangedSignature(state, currentPath)) {
120078
120134
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
120079
120135
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -120085,56 +120141,38 @@ var ts;
120085
120141
  var seenFileAndExportsOfFile = new ts.Set();
120086
120142
  // Go through exported modules from cache first
120087
120143
  // If exported modules has path, all files referencing file exported from are affected
120088
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120089
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120090
- });
120091
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120092
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
120093
- var _a;
120094
- // If the cache had an updated value, skip
120095
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120096
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
120097
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120144
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
120145
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
120146
+ return true;
120147
+ var references = state.referencedMap.getKeys(exportedFromPath);
120148
+ return references && ts.forEachKey(references, function (filePath) {
120149
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120150
+ });
120098
120151
  });
120099
120152
  }
120100
120153
  /**
120101
- * Iterate on files referencing referencedPath
120154
+ * handle dts and semantic diagnostics on file and iterate on anything that exports this file
120155
+ * return true when all work is done and we can exit handling dts emit and semantic diagnostics
120102
120156
  */
120103
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
120157
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
120104
120158
  var _a;
120105
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
120106
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
120107
- });
120108
- }
120109
- /**
120110
- * fn on file and iterate on anything that exports this file
120111
- */
120112
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
120113
- var _a, _b, _c;
120114
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
120115
- return;
120116
- }
120117
- fn(state, filePath);
120159
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
120160
+ return undefined;
120161
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
120162
+ return true;
120163
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
120118
120164
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
120119
- // Go through exported modules from cache first
120120
120165
  // If exported modules has path, all files referencing file exported from are affected
120121
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
120122
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120123
- });
120124
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
120125
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
120126
- var _a;
120127
- // If the cache had an updated value, skip
120128
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
120129
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
120130
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
120166
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
120167
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
120131
120168
  });
120132
120169
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
120133
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
120170
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
120134
120171
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
120135
- fn(state, referencingFilePath);
120136
- } // Dont add to seen since this is not yet done with the export removal
120137
- );
120172
+ handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
120173
+ state, referencingFilePath, cancellationToken, computeHash, host);
120174
+ });
120175
+ return undefined;
120138
120176
  }
120139
120177
  /**
120140
120178
  * This is called after completing operation on the next affected file.
@@ -120510,7 +120548,43 @@ var ts;
120510
120548
  return toAffectedFileEmitResult(state,
120511
120549
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
120512
120550
  // Otherwise just affected file
120513
- ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120551
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120552
+ getWriteFileUpdatingSignatureCallback(writeFile) :
120553
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120554
+ }
120555
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
120556
+ return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
120557
+ var _a;
120558
+ if (ts.isDeclarationFileName(fileName)) {
120559
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120560
+ var file = sourceFiles[0];
120561
+ var info = state.fileInfos.get(file.resolvedPath);
120562
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
120563
+ if (signature === file.version) {
120564
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
120565
+ if (newSignature !== file.version) { // Update it
120566
+ if (host.storeFilesChangingSignatureDuringEmit)
120567
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120568
+ if (state.exportedModulesMap)
120569
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
120570
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
120571
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
120572
+ }
120573
+ else {
120574
+ info.signature = newSignature;
120575
+ if (state.exportedModulesMap)
120576
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120577
+ }
120578
+ }
120579
+ }
120580
+ }
120581
+ if (writeFile)
120582
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120583
+ else if (host.writeFile)
120584
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120585
+ else
120586
+ state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120587
+ };
120514
120588
  }
120515
120589
  /**
120516
120590
  * Emits the JavaScript and declaration files.
@@ -120567,7 +120641,9 @@ var ts;
120567
120641
  }
120568
120642
  }
120569
120643
  }
120570
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120644
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120645
+ getWriteFileUpdatingSignatureCallback(writeFile) :
120646
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120571
120647
  }
120572
120648
  /**
120573
120649
  * Return the semantic diagnostics for the next affected file or undefined if iteration is complete
@@ -122759,6 +122835,7 @@ var ts;
122759
122835
  createHash: ts.maybeBind(host, host.createHash),
122760
122836
  readDirectory: ts.maybeBind(host, host.readDirectory),
122761
122837
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
122838
+ storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
122762
122839
  };
122763
122840
  function writeFile(fileName, text, writeByteOrderMark, onError) {
122764
122841
  try {
@@ -122818,6 +122895,7 @@ var ts;
122818
122895
  createHash: ts.maybeBind(system, system.createHash),
122819
122896
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
122820
122897
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
122898
+ storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
122821
122899
  };
122822
122900
  }
122823
122901
  ts.createProgramHost = createProgramHost;
@@ -122906,6 +122984,7 @@ var ts;
122906
122984
  var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system);
122907
122985
  host.createHash = ts.maybeBind(system, system.createHash);
122908
122986
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
122987
+ host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
122909
122988
  ts.setGetSourceFileAsHashVersioned(host, system);
122910
122989
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
122911
122990
  return host;
@@ -131655,7 +131734,7 @@ var ts;
131655
131734
  GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
131656
131735
  GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
131657
131736
  })(GlobalsSearch || (GlobalsSearch = {}));
131658
- function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
131737
+ function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
131659
131738
  var _a, _b, _c;
131660
131739
  var start = ts.timestamp();
131661
131740
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -131670,9 +131749,9 @@ var ts;
131670
131749
  (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete"));
131671
131750
  (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start));
131672
131751
  return result;
131673
- function tryResolve(exportInfo, isFromAmbientModule) {
131752
+ function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
131674
131753
  if (isFromAmbientModule) {
131675
- var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences);
131754
+ var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences);
131676
131755
  if (result_1) {
131677
131756
  ambientCount++;
131678
131757
  }
@@ -131681,7 +131760,7 @@ var ts;
131681
131760
  var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131682
131761
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
131683
131762
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
131684
- ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131763
+ ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131685
131764
  : undefined;
131686
131765
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
131687
131766
  resolutionLimitExceeded = true;
@@ -131786,8 +131865,8 @@ var ts;
131786
131865
  return undefined;
131787
131866
  var lowerCaseTokenText = location.text.toLowerCase();
131788
131867
  var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
131789
- var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences,
131790
- /*isForImportStatementCompletion*/ false, function (context) {
131868
+ var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
131869
+ /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
131791
131870
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
131792
131871
  if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
131793
131872
  // Not an auto import or already resolved; keep as is
@@ -131799,7 +131878,7 @@ var ts;
131799
131878
  }
131800
131879
  var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
131801
131880
  var info = exportMap.get(file.path, entry.data.exportMapKey);
131802
- var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131881
+ var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131803
131882
  if (!result)
131804
131883
  return entry;
131805
131884
  var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
@@ -132391,22 +132470,44 @@ var ts;
132391
132470
  }
132392
132471
  }
132393
132472
  function createSnippetPrinter(printerOptions) {
132473
+ var escapes;
132394
132474
  var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
132395
132475
  var printer = ts.createPrinter(printerOptions, baseWriter);
132396
- var writer = __assign(__assign({}, baseWriter), { write: function (s) { return baseWriter.write(ts.escapeSnippetText(s)); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return baseWriter.writeLiteral(ts.escapeSnippetText(s)); }, writeStringLiteral: function (s) { return baseWriter.writeStringLiteral(ts.escapeSnippetText(s)); }, writeSymbol: function (s, symbol) { return baseWriter.writeSymbol(ts.escapeSnippetText(s), symbol); }, writeParameter: function (s) { return baseWriter.writeParameter(ts.escapeSnippetText(s)); }, writeComment: function (s) { return baseWriter.writeComment(ts.escapeSnippetText(s)); }, writeProperty: function (s) { return baseWriter.writeProperty(ts.escapeSnippetText(s)); } });
132476
+ var writer = __assign(__assign({}, baseWriter), { write: function (s) { return escapingWrite(s, function () { return baseWriter.write(s); }); }, nonEscapingWrite: baseWriter.write, writeLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeLiteral(s); }); }, writeStringLiteral: function (s) { return escapingWrite(s, function () { return baseWriter.writeStringLiteral(s); }); }, writeSymbol: function (s, symbol) { return escapingWrite(s, function () { return baseWriter.writeSymbol(s, symbol); }); }, writeParameter: function (s) { return escapingWrite(s, function () { return baseWriter.writeParameter(s); }); }, writeComment: function (s) { return escapingWrite(s, function () { return baseWriter.writeComment(s); }); }, writeProperty: function (s) { return escapingWrite(s, function () { return baseWriter.writeProperty(s); }); } });
132397
132477
  return {
132398
132478
  printSnippetList: printSnippetList,
132399
132479
  printAndFormatSnippetList: printAndFormatSnippetList,
132400
132480
  };
132481
+ // The formatter/scanner will have issues with snippet-escaped text,
132482
+ // so instead of writing the escaped text directly to the writer,
132483
+ // generate a set of changes that can be applied to the unescaped text
132484
+ // to escape it post-formatting.
132485
+ function escapingWrite(s, write) {
132486
+ var escaped = ts.escapeSnippetText(s);
132487
+ if (escaped !== s) {
132488
+ var start = baseWriter.getTextPos();
132489
+ write();
132490
+ var end = baseWriter.getTextPos();
132491
+ escapes = ts.append(escapes || (escapes = []), { newText: escaped, span: { start: start, length: end - start } });
132492
+ }
132493
+ else {
132494
+ write();
132495
+ }
132496
+ }
132401
132497
  /* Snippet-escaping version of `printer.printList`. */
132402
132498
  function printSnippetList(format, list, sourceFile) {
132499
+ var unescaped = printUnescapedSnippetList(format, list, sourceFile);
132500
+ return escapes ? ts.textChanges.applyChanges(unescaped, escapes) : unescaped;
132501
+ }
132502
+ function printUnescapedSnippetList(format, list, sourceFile) {
132503
+ escapes = undefined;
132403
132504
  writer.clear();
132404
132505
  printer.writeList(format, list, sourceFile, writer);
132405
132506
  return writer.getText();
132406
132507
  }
132407
132508
  function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
132408
132509
  var syntheticFile = {
132409
- text: printSnippetList(format, list, sourceFile),
132510
+ text: printUnescapedSnippetList(format, list, sourceFile),
132410
132511
  getLineAndCharacterOfPosition: function (pos) {
132411
132512
  return ts.getLineAndCharacterOfPosition(this, pos);
132412
132513
  },
@@ -132418,7 +132519,10 @@ var ts;
132418
132519
  /* indentation */ 0,
132419
132520
  /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
132420
132521
  });
132421
- return ts.textChanges.applyChanges(syntheticFile.text, changes);
132522
+ var allChanges = escapes
132523
+ ? ts.stableSort(ts.concatenate(changes, escapes), function (a, b) { return ts.compareTextSpans(a.span, b.span); })
132524
+ : changes;
132525
+ return ts.textChanges.applyChanges(syntheticFile.text, allChanges);
132422
132526
  }
132423
132527
  }
132424
132528
  function originToCompletionEntryData(origin) {
@@ -133310,7 +133414,7 @@ var ts;
133310
133414
  moduleSymbol: moduleSymbol,
133311
133415
  symbol: firstAccessibleSymbol,
133312
133416
  targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
133313
- }], sourceFile, program, host, preferences) || {}).moduleSpecifier;
133417
+ }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
133314
133418
  if (moduleSpecifier) {
133315
133419
  var origin = {
133316
133420
  kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */),
@@ -133565,7 +133669,7 @@ var ts;
133565
133669
  var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
133566
133670
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
133567
133671
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
133568
- resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
133672
+ resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
133569
133673
  exportInfo.search(sourceFile.path,
133570
133674
  /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
133571
133675
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
@@ -133593,7 +133697,7 @@ var ts;
133593
133697
  }
133594
133698
  // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
133595
133699
  // (We need to ensure that at least one is importable to show a completion.)
133596
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
133700
+ var _a = context.tryResolve(info, symbolName, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
133597
133701
  var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
133598
133702
  var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
133599
133703
  pushAutoImportSymbol(symbol, {
@@ -152417,7 +152521,7 @@ var ts;
152417
152521
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
152418
152522
  var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
152419
152523
  var useRequire = shouldUseRequire(sourceFile, program);
152420
- var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
152524
+ var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
152421
152525
  if (fix) {
152422
152526
  addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
152423
152527
  }
@@ -152587,7 +152691,7 @@ var ts;
152587
152691
  : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
152588
152692
  var useRequire = shouldUseRequire(sourceFile, program);
152589
152693
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
152590
- var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
152694
+ var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, useRequire, host, preferences));
152591
152695
  return {
152592
152696
  moduleSpecifier: fix.moduleSpecifier,
152593
152697
  codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
@@ -152603,10 +152707,10 @@ var ts;
152603
152707
  return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
152604
152708
  }
152605
152709
  codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
152606
- function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152710
+ function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152607
152711
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
152608
152712
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
152609
- return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
152713
+ return getBestFix(getImportFixes(exportInfos, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host);
152610
152714
  }
152611
152715
  function codeFixActionToCodeAction(_a) {
152612
152716
  var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -152661,25 +152765,32 @@ var ts;
152661
152765
  return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
152662
152766
  }
152663
152767
  }
152664
- function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
152665
- var _a = getNewImportFixes(program, importingFile,
152666
- /*position*/ undefined,
152667
- /*isValidTypeOnlyUseSite*/ false,
152668
- /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
152768
+ function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
152769
+ var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
152770
+ /*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
152669
152771
  var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
152670
152772
  return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
152671
152773
  }
152672
152774
  codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
152673
- function getImportFixes(exportInfos, symbolName,
152775
+ function getImportFixes(exportInfos, useNamespaceInfo,
152674
152776
  /** undefined only for missing JSX namespace */
152675
- position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) {
152777
+ isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
152676
152778
  var checker = program.getTypeChecker();
152677
152779
  var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
152678
- var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker);
152780
+ var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
152679
152781
  var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
152680
- // Don't bother providing an action to add a new import if we can add to an existing one.
152681
- var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences);
152682
- return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true);
152782
+ if (addToExisting) {
152783
+ // Don't bother providing an action to add a new import if we can add to an existing one.
152784
+ return {
152785
+ computedWithoutCacheCount: 0,
152786
+ fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), [addToExisting], false),
152787
+ };
152788
+ }
152789
+ var _a = getFixesForAddImport(exportInfos, existingImports, program, sourceFile, useNamespaceInfo === null || useNamespaceInfo === void 0 ? void 0 : useNamespaceInfo.position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly), fixes = _a.fixes, _b = _a.computedWithoutCacheCount, computedWithoutCacheCount = _b === void 0 ? 0 : _b;
152790
+ return {
152791
+ computedWithoutCacheCount: computedWithoutCacheCount,
152792
+ fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), fixes, true),
152793
+ };
152683
152794
  }
152684
152795
  function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) {
152685
152796
  // It is possible that multiple import statements with the same specifier exist in the file.
@@ -152869,9 +152980,9 @@ var ts;
152869
152980
  });
152870
152981
  return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes };
152871
152982
  }
152872
- function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152983
+ function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) {
152873
152984
  var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); });
152874
- return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
152985
+ return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly);
152875
152986
  }
152876
152987
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
152877
152988
  var _b;
@@ -152967,7 +153078,8 @@ var ts;
152967
153078
  var symbolName = umdSymbol.name;
152968
153079
  var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
152969
153080
  var useRequire = shouldUseRequire(sourceFile, program);
152970
- var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
153081
+ var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined;
153082
+ var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes;
152971
153083
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
152972
153084
  }
152973
153085
  function getUmdSymbol(token, checker) {
@@ -153039,7 +153151,7 @@ var ts;
153039
153151
  var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
153040
153152
  var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
153041
153153
  var _ = _a[0], exportInfos = _a[1];
153042
- return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
153154
+ return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
153043
153155
  }));
153044
153156
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
153045
153157
  }