typescript 4.7.0-dev.20220420 → 4.7.0-dev.20220423

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
@@ -100,7 +100,7 @@ var ts;
100
100
  // The following is baselined as a literal template type without intervention
101
101
  /** The version of the TypeScript compiler release */
102
102
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220420";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220423";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -14702,7 +14702,7 @@ var ts;
14702
14702
  var _a;
14703
14703
  // If we don't need to downlevel and we can reach the original source text using
14704
14704
  // the node's parent reference, then simply get the text as it was originally written.
14705
- if (canUseOriginalText(node, flags)) {
14705
+ if (sourceFile && canUseOriginalText(node, flags)) {
14706
14706
  return getSourceTextOfNodeFromSourceFile(sourceFile, node);
14707
14707
  }
14708
14708
  // If we can't reach the original source text, use the canonical form if it's a number,
@@ -18293,10 +18293,10 @@ var ts;
18293
18293
  return ts.combinePaths(newDirPath, sourceFilePath);
18294
18294
  }
18295
18295
  ts.getSourceFilePathInNewDirWorker = getSourceFilePathInNewDirWorker;
18296
- function writeFile(host, diagnostics, fileName, data, writeByteOrderMark, sourceFiles) {
18297
- host.writeFile(fileName, data, writeByteOrderMark, function (hostErrorMessage) {
18296
+ function writeFile(host, diagnostics, fileName, text, writeByteOrderMark, sourceFiles, data) {
18297
+ host.writeFile(fileName, text, writeByteOrderMark, function (hostErrorMessage) {
18298
18298
  diagnostics.add(createCompilerDiagnostic(ts.Diagnostics.Could_not_write_file_0_Colon_1, fileName, hostErrorMessage));
18299
- }, sourceFiles);
18299
+ }, sourceFiles, data);
18300
18300
  }
18301
18301
  ts.writeFile = writeFile;
18302
18302
  function ensureDirectoriesExist(directoryPath, createDirectory, directoryExists) {
@@ -73432,6 +73432,7 @@ var ts;
73432
73432
  }
73433
73433
  }
73434
73434
  else {
73435
+ error(attributeDecl.expression, ts.Diagnostics.Spread_types_may_only_be_created_from_object_types);
73435
73436
  typeToIntersect = typeToIntersect ? getIntersectionType([typeToIntersect, exprType]) : exprType;
73436
73437
  }
73437
73438
  }
@@ -75669,6 +75670,7 @@ var ts;
75669
75670
  // decorators are applied to a declaration by the emitter, and not to an expression.
75670
75671
  var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75671
75672
  var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
75673
+ argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75672
75674
  // The following variables are captured and modified by calls to chooseOverload.
75673
75675
  // If overload resolution or type argument inference fails, we want to report the
75674
75676
  // best error possible. The best error is one which says that an argument was not
@@ -75884,7 +75886,7 @@ var ts;
75884
75886
  // If one or more context sensitive arguments were excluded, we start including
75885
75887
  // them now (and keeping do so for any subsequent candidates) and perform a second
75886
75888
  // round of type inference and applicability checking for this particular candidate.
75887
- argCheckMode = 0 /* Normal */;
75889
+ argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75888
75890
  if (inferenceContext) {
75889
75891
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
75890
75892
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -94696,7 +94698,7 @@ var ts;
94696
94698
  }
94697
94699
  resumeLexicalEnvironment();
94698
94700
  var needsSyntheticConstructor = !constructor && isDerivedClass;
94699
- var indexOfFirstStatementAfterSuper = 0;
94701
+ var indexOfFirstStatementAfterSuperAndPrologue = 0;
94700
94702
  var prologueStatementCount = 0;
94701
94703
  var superStatementIndex = -1;
94702
94704
  var statements = [];
@@ -94705,8 +94707,11 @@ var ts;
94705
94707
  superStatementIndex = ts.findSuperStatementIndex(constructor.body.statements, prologueStatementCount);
94706
94708
  // If there was a super call, visit existing statements up to and including it
94707
94709
  if (superStatementIndex >= 0) {
94708
- indexOfFirstStatementAfterSuper = superStatementIndex + 1;
94709
- statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuper - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
94710
+ indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1;
94711
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, prologueStatementCount), true), ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), true), statements.slice(prologueStatementCount), true);
94712
+ }
94713
+ else if (prologueStatementCount >= 0) {
94714
+ indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount;
94710
94715
  }
94711
94716
  }
94712
94717
  if (needsSyntheticConstructor) {
@@ -94742,22 +94747,20 @@ var ts;
94742
94747
  }
94743
94748
  }
94744
94749
  if (parameterPropertyDeclarationCount > 0) {
94745
- var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuper, parameterPropertyDeclarationCount);
94750
+ var parameterProperties = ts.visitNodes(constructor.body.statements, visitor, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue, parameterPropertyDeclarationCount);
94746
94751
  // If there was a super() call found, add parameter properties immediately after it
94747
94752
  if (superStatementIndex >= 0) {
94748
94753
  ts.addRange(statements, parameterProperties);
94749
94754
  }
94750
- // If a synthetic super() call was added, add them just after it
94751
- else if (needsSyntheticConstructor) {
94752
- statements = __spreadArray(__spreadArray([
94753
- statements[0]
94754
- ], parameterProperties, true), statements.slice(1), true);
94755
- }
94756
- // Since there wasn't a super() call, add them to the top of the constructor
94757
94755
  else {
94758
- statements = __spreadArray(__spreadArray([], parameterProperties, true), statements, true);
94756
+ // Add add parameter properties to the top of the constructor after the prologue
94757
+ var superAndPrologueStatementCount = prologueStatementCount;
94758
+ // If a synthetic super() call was added, need to account for that
94759
+ if (needsSyntheticConstructor)
94760
+ superAndPrologueStatementCount++;
94761
+ statements = __spreadArray(__spreadArray(__spreadArray([], statements.slice(0, superAndPrologueStatementCount), true), parameterProperties, true), statements.slice(superAndPrologueStatementCount), true);
94759
94762
  }
94760
- indexOfFirstStatementAfterSuper += parameterPropertyDeclarationCount;
94763
+ indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount;
94761
94764
  }
94762
94765
  }
94763
94766
  }
@@ -94767,7 +94770,7 @@ var ts;
94767
94770
  addPropertyOrClassStaticBlockStatements(statements, properties, receiver);
94768
94771
  // Add existing statements after the initial prologues and super call
94769
94772
  if (constructor) {
94770
- ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuper + prologueStatementCount));
94773
+ ts.addRange(statements, ts.visitNodes(constructor.body.statements, visitBodyStatement, ts.isStatement, indexOfFirstStatementAfterSuperAndPrologue));
94771
94774
  }
94772
94775
  statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment());
94773
94776
  return ts.setTextRange(factory.createBlock(ts.setTextRange(factory.createNodeArray(statements),
@@ -109965,6 +109968,7 @@ var ts;
109965
109968
  else {
109966
109969
  printer.writeFile(sourceFile, writer, sourceMapGenerator);
109967
109970
  }
109971
+ var sourceMapUrlPos;
109968
109972
  if (sourceMapGenerator) {
109969
109973
  if (sourceMapDataList) {
109970
109974
  sourceMapDataList.push({
@@ -109976,6 +109980,7 @@ var ts;
109976
109980
  if (sourceMappingURL) {
109977
109981
  if (!writer.isAtStartOfLine())
109978
109982
  writer.rawWrite(newLine);
109983
+ sourceMapUrlPos = writer.getTextPos();
109979
109984
  writer.writeComment("//# " + "sourceMappingURL" + "=" + sourceMappingURL); // Tools can sometimes see this line as a source mapping url comment
109980
109985
  }
109981
109986
  // Write the source map
@@ -109988,7 +109993,7 @@ var ts;
109988
109993
  writer.writeLine();
109989
109994
  }
109990
109995
  // Write the output file
109991
- ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles);
109996
+ ts.writeFile(host, emitterDiagnostics, jsFilePath, writer.getText(), !!compilerOptions.emitBOM, sourceFiles, { sourceMapUrlPos: sourceMapUrlPos });
109992
109997
  // Reset state
109993
109998
  writer.clear();
109994
109999
  }
@@ -110510,7 +110515,7 @@ var ts;
110510
110515
  setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined);
110511
110516
  }
110512
110517
  function getCurrentLineMap() {
110513
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
110518
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
110514
110519
  }
110515
110520
  function emit(node, parenthesizerRule) {
110516
110521
  if (node === undefined)
@@ -111685,7 +111690,7 @@ var ts;
111685
111690
  increaseIndent();
111686
111691
  }
111687
111692
  var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */;
111688
- var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */;
111693
+ var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */;
111689
111694
  emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine);
111690
111695
  if (indentedFlag) {
111691
111696
  decreaseIndent();
@@ -112041,7 +112046,7 @@ var ts;
112041
112046
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
112042
112047
  // Emit semicolon in non json files
112043
112048
  // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation)
112044
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112049
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112045
112050
  writeTrailingSemicolon();
112046
112051
  }
112047
112052
  }
@@ -112334,7 +112339,7 @@ var ts;
112334
112339
  if (body.multiLine) {
112335
112340
  return false;
112336
112341
  }
112337
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112342
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112338
112343
  return false;
112339
112344
  }
112340
112345
  if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)
@@ -112359,12 +112364,7 @@ var ts;
112359
112364
  var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
112360
112365
  ? emitBlockFunctionBodyOnSingleLine
112361
112366
  : emitBlockFunctionBodyWorker;
112362
- if (emitBodyWithDetachedComments) {
112363
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112364
- }
112365
- else {
112366
- emitBlockFunctionBody(body);
112367
- }
112367
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112368
112368
  decreaseIndent();
112369
112369
  writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body);
112370
112370
  onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
@@ -112761,7 +112761,8 @@ var ts;
112761
112761
  var emitAsSingleStatement = statements.length === 1 &&
112762
112762
  (
112763
112763
  // treat synthesized nodes as located on the same line for emit purposes
112764
- ts.nodeIsSynthesized(parentNode) ||
112764
+ !currentSourceFile ||
112765
+ ts.nodeIsSynthesized(parentNode) ||
112765
112766
  ts.nodeIsSynthesized(statements[0]) ||
112766
112767
  ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
112767
112768
  var format = 163969 /* CaseOrDefaultClauseStatements */;
@@ -112992,16 +112993,14 @@ var ts;
112992
112993
  function emitSourceFile(node) {
112993
112994
  writeLine();
112994
112995
  var statements = node.statements;
112995
- if (emitBodyWithDetachedComments) {
112996
- // Emit detached comment if there are no prologue directives or if the first node is synthesized.
112997
- // The synthesized node will have no leading comment so some comments may be missed.
112998
- var shouldEmitDetachedComment = statements.length === 0 ||
112999
- !ts.isPrologueDirective(statements[0]) ||
113000
- ts.nodeIsSynthesized(statements[0]);
113001
- if (shouldEmitDetachedComment) {
113002
- emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
113003
- return;
113004
- }
112996
+ // Emit detached comment if there are no prologue directives or if the first node is synthesized.
112997
+ // The synthesized node will have no leading comment so some comments may be missed.
112998
+ var shouldEmitDetachedComment = statements.length === 0 ||
112999
+ !ts.isPrologueDirective(statements[0]) ||
113000
+ ts.nodeIsSynthesized(statements[0]);
113001
+ if (shouldEmitDetachedComment) {
113002
+ emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
113003
+ return;
113005
113004
  }
113006
113005
  emitSourceFileWorker(node);
113007
113006
  }
@@ -113390,7 +113389,7 @@ var ts;
113390
113389
  }
113391
113390
  if (isEmpty) {
113392
113391
  // Write a line terminator if the parent node was multi-line
113393
- if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113392
+ if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113394
113393
  writeLine();
113395
113394
  }
113396
113395
  else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) {
@@ -113651,7 +113650,7 @@ var ts;
113651
113650
  }
113652
113651
  var firstChild_1 = children[0];
113653
113652
  if (firstChild_1 === undefined) {
113654
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113653
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113655
113654
  }
113656
113655
  if (firstChild_1.pos === nextListElementPos) {
113657
113656
  // If this child starts at the beginning of a list item in a parent list, its leading
@@ -113675,7 +113674,7 @@ var ts;
113675
113674
  // JsxText will be written with its leading whitespace, so don't add more manually.
113676
113675
  return 0;
113677
113676
  }
113678
- if (parentNode &&
113677
+ if (currentSourceFile && parentNode &&
113679
113678
  !ts.positionIsSynthesized(parentNode.pos) &&
113680
113679
  !ts.nodeIsSynthesized(firstChild_1) &&
113681
113680
  (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -113699,7 +113698,7 @@ var ts;
113699
113698
  // JsxText will be written with its leading whitespace, so don't add more manually.
113700
113699
  return 0;
113701
113700
  }
113702
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113701
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113703
113702
  if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
113704
113703
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
113705
113704
  }
@@ -113731,9 +113730,9 @@ var ts;
113731
113730
  }
113732
113731
  var lastChild = ts.lastOrUndefined(children);
113733
113732
  if (lastChild === undefined) {
113734
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113733
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113735
113734
  }
113736
- if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
113735
+ if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
113737
113736
  if (preserveSourceNewlines) {
113738
113737
  var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
113739
113738
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -113806,7 +113805,7 @@ var ts;
113806
113805
  if (ts.getStartsOnNewLine(node2)) {
113807
113806
  return 1;
113808
113807
  }
113809
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
113808
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
113810
113809
  if (preserveSourceNewlines) {
113811
113810
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
113812
113811
  }
@@ -113816,7 +113815,7 @@ var ts;
113816
113815
  }
113817
113816
  function isEmptyBlock(block) {
113818
113817
  return block.statements.length === 0
113819
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
113818
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
113820
113819
  }
113821
113820
  function skipSynthesizedParentheses(node) {
113822
113821
  while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) {
@@ -113828,16 +113827,23 @@ var ts;
113828
113827
  if (ts.isGeneratedIdentifier(node)) {
113829
113828
  return generateName(node);
113830
113829
  }
113831
- else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
113832
- return ts.idText(node);
113833
- }
113834
- else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
113830
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
113835
113831
  return getTextOfNode(node.textSourceNode, includeTrivia);
113836
113832
  }
113837
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
113838
- return node.text;
113833
+ var sourceFile = currentSourceFile; // const needed for control flow
113834
+ var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
113835
+ if (ts.isMemberName(node)) {
113836
+ if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
113837
+ return ts.idText(node);
113838
+ }
113839
+ }
113840
+ else {
113841
+ ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary
113842
+ if (!canUseSourceFile) {
113843
+ return node.text;
113844
+ }
113839
113845
  }
113840
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
113846
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
113841
113847
  }
113842
113848
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
113843
113849
  if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
@@ -114416,7 +114422,7 @@ var ts;
114416
114422
  return true;
114417
114423
  }
114418
114424
  function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
114419
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114425
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114420
114426
  return;
114421
114427
  if (!hasWrittenComment) {
114422
114428
  ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -114443,7 +114449,7 @@ var ts;
114443
114449
  forEachTrailingCommentToEmit(pos, emitTrailingComment);
114444
114450
  }
114445
114451
  function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114446
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114452
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114447
114453
  return;
114448
114454
  // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
114449
114455
  if (!writer.isAtStartOfLine()) {
@@ -114465,6 +114471,8 @@ var ts;
114465
114471
  exitComment();
114466
114472
  }
114467
114473
  function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
114474
+ if (!currentSourceFile)
114475
+ return;
114468
114476
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114469
114477
  emitPos(commentPos);
114470
114478
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114474,6 +114482,8 @@ var ts;
114474
114482
  }
114475
114483
  }
114476
114484
  function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114485
+ if (!currentSourceFile)
114486
+ return;
114477
114487
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114478
114488
  emitPos(commentPos);
114479
114489
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114506,6 +114516,8 @@ var ts;
114506
114516
  return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
114507
114517
  }
114508
114518
  function forEachLeadingCommentWithoutDetachedComments(cb) {
114519
+ if (!currentSourceFile)
114520
+ return;
114509
114521
  // get the leading comments from detachedPos
114510
114522
  var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
114511
114523
  if (detachedCommentsInfo.length - 1) {
@@ -114517,7 +114529,7 @@ var ts;
114517
114529
  ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos);
114518
114530
  }
114519
114531
  function emitDetachedCommentsAndUpdateCommentsInfo(range) {
114520
- var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
114532
+ var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
114521
114533
  if (currentDetachedCommentInfo) {
114522
114534
  if (detachedCommentsInfo) {
114523
114535
  detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -114528,7 +114540,7 @@ var ts;
114528
114540
  }
114529
114541
  }
114530
114542
  function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
114531
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114543
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114532
114544
  return;
114533
114545
  emitPos(commentPos);
114534
114546
  ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
@@ -114540,7 +114552,7 @@ var ts;
114540
114552
  * @return true if the comment is a triple-slash comment else false
114541
114553
  */
114542
114554
  function isTripleSlashComment(commentPos, commentEnd) {
114543
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114555
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114544
114556
  }
114545
114557
  // Source Maps
114546
114558
  function getParsedSourceMap(node) {
@@ -115455,7 +115467,11 @@ var ts;
115455
115467
  return newValue;
115456
115468
  };
115457
115469
  if (originalWriteFile) {
115458
- host.writeFile = function (fileName, data, writeByteOrderMark, onError, sourceFiles) {
115470
+ host.writeFile = function (fileName, data) {
115471
+ var rest = [];
115472
+ for (var _i = 2; _i < arguments.length; _i++) {
115473
+ rest[_i - 2] = arguments[_i];
115474
+ }
115459
115475
  var key = toPath(fileName);
115460
115476
  fileExistsCache.delete(key);
115461
115477
  var value = readFileCache.get(key);
@@ -115469,7 +115485,7 @@ var ts;
115469
115485
  sourceFileCache.delete(key);
115470
115486
  }
115471
115487
  }
115472
- originalWriteFile.call(host, fileName, data, writeByteOrderMark, onError, sourceFiles);
115488
+ originalWriteFile.call.apply(originalWriteFile, __spreadArray([host, fileName, data], rest, false));
115473
115489
  };
115474
115490
  }
115475
115491
  // directoryExists
@@ -116402,6 +116418,7 @@ var ts;
116402
116418
  useCaseSensitiveFileNames: function () { return host.useCaseSensitiveFileNames(); },
116403
116419
  getFileIncludeReasons: function () { return fileReasons; },
116404
116420
  structureIsReused: structureIsReused,
116421
+ writeFile: writeFile,
116405
116422
  };
116406
116423
  onProgramCreateComplete();
116407
116424
  // Add file processingDiagnostics
@@ -116899,7 +116916,7 @@ var ts;
116899
116916
  getProjectReferenceRedirect: getProjectReferenceRedirect,
116900
116917
  isSourceOfProjectReferenceRedirect: isSourceOfProjectReferenceRedirect,
116901
116918
  getSymlinkCache: getSymlinkCache,
116902
- writeFile: writeFileCallback || (function (fileName, data, writeByteOrderMark, onError, sourceFiles) { return host.writeFile(fileName, data, writeByteOrderMark, onError, sourceFiles); }),
116919
+ writeFile: writeFileCallback || writeFile,
116903
116920
  isEmitBlocked: isEmitBlocked,
116904
116921
  readFile: function (f) { return host.readFile(f); },
116905
116922
  fileExists: function (f) {
@@ -116919,6 +116936,9 @@ var ts;
116919
116936
  getFileIncludeReasons: program.getFileIncludeReasons,
116920
116937
  };
116921
116938
  }
116939
+ function writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
116940
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
116941
+ }
116922
116942
  function emitBuildInfo(writeFileCallback) {
116923
116943
  ts.Debug.assert(!ts.outFile(options));
116924
116944
  ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("emit" /* Emit */, "emitBuildInfo", {}, /*separateBeginAndEnd*/ true);
@@ -119361,6 +119381,7 @@ var ts;
119361
119381
  }
119362
119382
  }
119363
119383
  }
119384
+ BuilderState.updateExportedModules = updateExportedModules;
119364
119385
  /**
119365
119386
  * Updates the exported modules from cache into state's exported modules map
119366
119387
  * This should be called whenever it is safe to commit the state of the builder
@@ -119784,6 +119805,18 @@ var ts;
119784
119805
  }
119785
119806
  return undefined;
119786
119807
  }
119808
+ function removeDiagnosticsOfLibraryFiles(state) {
119809
+ if (!state.cleanedDiagnosticsOfLibFiles) {
119810
+ state.cleanedDiagnosticsOfLibFiles = true;
119811
+ var program_1 = ts.Debug.checkDefined(state.program);
119812
+ var options_2 = program_1.getCompilerOptions();
119813
+ ts.forEach(program_1.getSourceFiles(), function (f) {
119814
+ return program_1.isSourceFileDefaultLibrary(f) &&
119815
+ !ts.skipTypeChecking(f, options_2, program_1) &&
119816
+ removeSemanticDiagnosticsOf(state, f.resolvedPath);
119817
+ });
119818
+ }
119819
+ }
119787
119820
  /**
119788
119821
  * Handles semantic diagnostics and dts emit for affectedFile and files, that are referencing modules that export entities from affected file
119789
119822
  * This is because even though js emit doesnt change, dts emit / type used can change resulting in need for dts emit and js change
@@ -119793,28 +119826,17 @@ var ts;
119793
119826
  removeSemanticDiagnosticsOf(state, affectedFile.resolvedPath);
119794
119827
  // If affected files is everything except default library, then nothing more to do
119795
119828
  if (state.allFilesExcludingDefaultLibraryFile === state.affectedFiles) {
119796
- if (!state.cleanedDiagnosticsOfLibFiles) {
119797
- state.cleanedDiagnosticsOfLibFiles = true;
119798
- var program_1 = ts.Debug.checkDefined(state.program);
119799
- var options_2 = program_1.getCompilerOptions();
119800
- ts.forEach(program_1.getSourceFiles(), function (f) {
119801
- return program_1.isSourceFileDefaultLibrary(f) &&
119802
- !ts.skipTypeChecking(f, options_2, program_1) &&
119803
- removeSemanticDiagnosticsOf(state, f.resolvedPath);
119804
- });
119805
- }
119829
+ removeDiagnosticsOfLibraryFiles(state);
119806
119830
  // When a change affects the global scope, all files are considered to be affected without updating their signature
119807
119831
  // That means when affected file is handled, its signature can be out of date
119808
119832
  // To avoid this, ensure that we update the signature for any affected file in this scenario.
119809
119833
  ts.BuilderState.updateShapeSignature(state, ts.Debug.checkDefined(state.program), affectedFile, ts.Debug.checkDefined(state.currentAffectedFilesSignatures), cancellationToken, computeHash, state.currentAffectedFilesExportedModulesMap);
119810
119834
  return;
119811
119835
  }
119812
- else {
119813
- 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);
119814
- }
119815
- if (!state.compilerOptions.assumeChangesOnlyAffectDirectDependencies) {
119816
- forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, function (state, path) { return handleDtsMayChangeOf(state, path, cancellationToken, computeHash, host); });
119817
- }
119836
+ 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);
119837
+ if (state.compilerOptions.assumeChangesOnlyAffectDirectDependencies)
119838
+ return;
119839
+ handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host);
119818
119840
  }
119819
119841
  /**
119820
119842
  * Handle the dts may change, so they need to be added to pending emit if dts emit is enabled,
@@ -119856,16 +119878,41 @@ var ts;
119856
119878
  var oldSignature = ts.Debug.checkDefined(state.fileInfos.get(path)).signature;
119857
119879
  return newSignature !== oldSignature;
119858
119880
  }
119881
+ function forEachKeyOfExportedModulesMap(state, filePath, fn) {
119882
+ // Go through exported modules from cache first
119883
+ var keys = state.currentAffectedFilesExportedModulesMap.getKeys(filePath);
119884
+ var result = keys && ts.forEachKey(keys, fn);
119885
+ if (result)
119886
+ return result;
119887
+ // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
119888
+ keys = state.exportedModulesMap.getKeys(filePath);
119889
+ return keys && ts.forEachKey(keys, function (exportedFromPath) {
119890
+ var _a;
119891
+ // If the cache had an updated value, skip
119892
+ return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
119893
+ !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) ?
119894
+ fn(exportedFromPath) :
119895
+ undefined;
119896
+ });
119897
+ }
119898
+ function handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host) {
119899
+ var _a;
119900
+ if (!((_a = state.fileInfos.get(filePath)) === null || _a === void 0 ? void 0 : _a.affectsGlobalScope))
119901
+ return false;
119902
+ // Every file needs to be handled
119903
+ ts.BuilderState.getAllFilesExcludingDefaultLibraryFile(state, state.program, /*firstSourceFile*/ undefined)
119904
+ .forEach(function (file) { return handleDtsMayChangeOf(state, file.resolvedPath, cancellationToken, computeHash, host); });
119905
+ removeDiagnosticsOfLibraryFiles(state);
119906
+ return true;
119907
+ }
119859
119908
  /**
119860
- * Iterate on referencing modules that export entities from affected file
119909
+ * Iterate on referencing modules that export entities from affected file and delete diagnostics and add pending emit
119861
119910
  */
119862
- function forEachReferencingModulesOfExportOfAffectedFile(state, affectedFile, fn) {
119863
- var _a, _b;
119911
+ function handleDtsMayChangeOfReferencingExportOfAffectedFile(state, affectedFile, cancellationToken, computeHash, host) {
119864
119912
  // If there was change in signature (dts output) for the changed file,
119865
119913
  // then only we need to handle pending file emit
119866
- if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath)) {
119914
+ if (!state.exportedModulesMap || !state.changedFilesSet.has(affectedFile.resolvedPath))
119867
119915
  return;
119868
- }
119869
119916
  if (!isChangedSignature(state, affectedFile.resolvedPath))
119870
119917
  return;
119871
119918
  // Since isolated modules dont change js files, files affected by change in signature is itself
@@ -119878,7 +119925,9 @@ var ts;
119878
119925
  var currentPath = queue.pop();
119879
119926
  if (!seenFileNamesMap.has(currentPath)) {
119880
119927
  seenFileNamesMap.set(currentPath, true);
119881
- fn(state, currentPath);
119928
+ if (handleDtsMayChangeOfGlobalScope(state, currentPath, cancellationToken, computeHash, host))
119929
+ return;
119930
+ handleDtsMayChangeOf(state, currentPath, cancellationToken, computeHash, host);
119882
119931
  if (isChangedSignature(state, currentPath)) {
119883
119932
  var currentSourceFile = ts.Debug.checkDefined(state.program).getSourceFileByPath(currentPath);
119884
119933
  queue.push.apply(queue, ts.BuilderState.getReferencedByPaths(state, currentSourceFile.resolvedPath));
@@ -119890,56 +119939,38 @@ var ts;
119890
119939
  var seenFileAndExportsOfFile = new ts.Set();
119891
119940
  // Go through exported modules from cache first
119892
119941
  // If exported modules has path, all files referencing file exported from are affected
119893
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
119894
- return forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119895
- });
119896
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
119897
- (_b = state.exportedModulesMap.getKeys(affectedFile.resolvedPath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
119898
- var _a;
119899
- // If the cache had an updated value, skip
119900
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
119901
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
119902
- forEachFilesReferencingPath(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119942
+ forEachKeyOfExportedModulesMap(state, affectedFile.resolvedPath, function (exportedFromPath) {
119943
+ if (handleDtsMayChangeOfGlobalScope(state, exportedFromPath, cancellationToken, computeHash, host))
119944
+ return true;
119945
+ var references = state.referencedMap.getKeys(exportedFromPath);
119946
+ return references && ts.forEachKey(references, function (filePath) {
119947
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
119948
+ });
119903
119949
  });
119904
119950
  }
119905
119951
  /**
119906
- * Iterate on files referencing referencedPath
119952
+ * handle dts and semantic diagnostics on file and iterate on anything that exports this file
119953
+ * return true when all work is done and we can exit handling dts emit and semantic diagnostics
119907
119954
  */
119908
- function forEachFilesReferencingPath(state, referencedPath, seenFileAndExportsOfFile, fn) {
119955
+ function handleDtsMayChangeOfFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, cancellationToken, computeHash, host) {
119909
119956
  var _a;
119910
- (_a = state.referencedMap.getKeys(referencedPath)) === null || _a === void 0 ? void 0 : _a.forEach(function (filePath) {
119911
- return forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn);
119912
- });
119913
- }
119914
- /**
119915
- * fn on file and iterate on anything that exports this file
119916
- */
119917
- function forEachFileAndExportsOfFile(state, filePath, seenFileAndExportsOfFile, fn) {
119918
- var _a, _b, _c;
119919
- if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath)) {
119920
- return;
119921
- }
119922
- fn(state, filePath);
119957
+ if (!ts.tryAddToSet(seenFileAndExportsOfFile, filePath))
119958
+ return undefined;
119959
+ if (handleDtsMayChangeOfGlobalScope(state, filePath, cancellationToken, computeHash, host))
119960
+ return true;
119961
+ handleDtsMayChangeOf(state, filePath, cancellationToken, computeHash, host);
119923
119962
  ts.Debug.assert(!!state.currentAffectedFilesExportedModulesMap);
119924
- // Go through exported modules from cache first
119925
119963
  // If exported modules has path, all files referencing file exported from are affected
119926
- (_a = state.currentAffectedFilesExportedModulesMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (exportedFromPath) {
119927
- return forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119928
- });
119929
- // If exported from path is not from cache and exported modules has path, all files referencing file exported from are affected
119930
- (_b = state.exportedModulesMap.getKeys(filePath)) === null || _b === void 0 ? void 0 : _b.forEach(function (exportedFromPath) {
119931
- var _a;
119932
- // If the cache had an updated value, skip
119933
- return !state.currentAffectedFilesExportedModulesMap.hasKey(exportedFromPath) &&
119934
- !((_a = state.currentAffectedFilesExportedModulesMap.deletedKeys()) === null || _a === void 0 ? void 0 : _a.has(exportedFromPath)) &&
119935
- forEachFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, fn);
119964
+ forEachKeyOfExportedModulesMap(state, filePath, function (exportedFromPath) {
119965
+ return handleDtsMayChangeOfFileAndExportsOfFile(state, exportedFromPath, seenFileAndExportsOfFile, cancellationToken, computeHash, host);
119936
119966
  });
119937
119967
  // Remove diagnostics of files that import this file (without going to exports of referencing files)
119938
- (_c = state.referencedMap.getKeys(filePath)) === null || _c === void 0 ? void 0 : _c.forEach(function (referencingFilePath) {
119968
+ (_a = state.referencedMap.getKeys(filePath)) === null || _a === void 0 ? void 0 : _a.forEach(function (referencingFilePath) {
119939
119969
  return !seenFileAndExportsOfFile.has(referencingFilePath) && // Not already removed diagnostic file
119940
- fn(state, referencingFilePath);
119941
- } // Dont add to seen since this is not yet done with the export removal
119942
- );
119970
+ handleDtsMayChangeOf(// Dont add to seen since this is not yet done with the export removal
119971
+ state, referencingFilePath, cancellationToken, computeHash, host);
119972
+ });
119973
+ return undefined;
119943
119974
  }
119944
119975
  /**
119945
119976
  * This is called after completing operation on the next affected file.
@@ -120315,7 +120346,43 @@ var ts;
120315
120346
  return toAffectedFileEmitResult(state,
120316
120347
  // When whole program is affected, do emit only once (eg when --out or --outFile is specified)
120317
120348
  // Otherwise just affected file
120318
- 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);
120349
+ ts.Debug.checkDefined(state.program).emit(affected === state.program ? undefined : affected, affected !== state.program && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120350
+ getWriteFileUpdatingSignatureCallback(writeFile) :
120351
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles || emitKind === 0 /* DtsOnly */, customTransformers), affected, emitKind, isPendingEmitFile);
120352
+ }
120353
+ function getWriteFileUpdatingSignatureCallback(writeFile) {
120354
+ return function (fileName, text, writeByteOrderMark, onError, sourceFiles, data) {
120355
+ var _a;
120356
+ if (ts.isDeclarationFileName(fileName)) {
120357
+ ts.Debug.assert((sourceFiles === null || sourceFiles === void 0 ? void 0 : sourceFiles.length) === 1);
120358
+ var file = sourceFiles[0];
120359
+ var info = state.fileInfos.get(file.resolvedPath);
120360
+ var signature = ((_a = state.currentAffectedFilesSignatures) === null || _a === void 0 ? void 0 : _a.get(file.resolvedPath)) || info.signature;
120361
+ if (signature === file.version) {
120362
+ var newSignature = (computeHash || ts.generateDjb2Hash)((data === null || data === void 0 ? void 0 : data.sourceMapUrlPos) !== undefined ? text.substring(0, data.sourceMapUrlPos) : text);
120363
+ if (newSignature !== file.version) { // Update it
120364
+ if (host.storeFilesChangingSignatureDuringEmit)
120365
+ (state.filesChangingSignature || (state.filesChangingSignature = new ts.Set())).add(file.resolvedPath);
120366
+ if (state.exportedModulesMap)
120367
+ ts.BuilderState.updateExportedModules(file, file.exportedModulesFromDeclarationEmit, state.currentAffectedFilesExportedModulesMap || (state.currentAffectedFilesExportedModulesMap = ts.BuilderState.createManyToManyPathMap()));
120368
+ if (state.affectedFiles && state.affectedFilesIndex < state.affectedFiles.length) {
120369
+ state.currentAffectedFilesSignatures.set(file.resolvedPath, newSignature);
120370
+ }
120371
+ else {
120372
+ info.signature = newSignature;
120373
+ if (state.exportedModulesMap)
120374
+ ts.BuilderState.updateExportedFilesMapFromCache(state, state.currentAffectedFilesExportedModulesMap);
120375
+ }
120376
+ }
120377
+ }
120378
+ }
120379
+ if (writeFile)
120380
+ writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120381
+ else if (host.writeFile)
120382
+ host.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120383
+ else
120384
+ state.program.writeFile(fileName, text, writeByteOrderMark, onError, sourceFiles, data);
120385
+ };
120319
120386
  }
120320
120387
  /**
120321
120388
  * Emits the JavaScript and declaration files.
@@ -120372,7 +120439,9 @@ var ts;
120372
120439
  }
120373
120440
  }
120374
120441
  }
120375
- return ts.Debug.checkDefined(state.program).emit(targetSourceFile, writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120442
+ return ts.Debug.checkDefined(state.program).emit(targetSourceFile, !ts.outFile(state.compilerOptions) && ts.getEmitDeclarations(state.compilerOptions) && !customTransformers ?
120443
+ getWriteFileUpdatingSignatureCallback(writeFile) :
120444
+ writeFile || ts.maybeBind(host, host.writeFile), cancellationToken, emitOnlyDtsFiles, customTransformers);
120376
120445
  }
120377
120446
  /**
120378
120447
  * Return the semantic diagnostics for the next affected file or undefined if iteration is complete
@@ -122564,6 +122633,7 @@ var ts;
122564
122633
  createHash: ts.maybeBind(host, host.createHash),
122565
122634
  readDirectory: ts.maybeBind(host, host.readDirectory),
122566
122635
  disableUseFileVersionAsSignature: host.disableUseFileVersionAsSignature,
122636
+ storeFilesChangingSignatureDuringEmit: host.storeFilesChangingSignatureDuringEmit,
122567
122637
  };
122568
122638
  function writeFile(fileName, text, writeByteOrderMark, onError) {
122569
122639
  try {
@@ -122623,6 +122693,7 @@ var ts;
122623
122693
  createHash: ts.maybeBind(system, system.createHash),
122624
122694
  createProgram: createProgram || ts.createEmitAndSemanticDiagnosticsBuilderProgram,
122625
122695
  disableUseFileVersionAsSignature: system.disableUseFileVersionAsSignature,
122696
+ storeFilesChangingSignatureDuringEmit: system.storeFilesChangingSignatureDuringEmit,
122626
122697
  };
122627
122698
  }
122628
122699
  ts.createProgramHost = createProgramHost;
@@ -122711,6 +122782,7 @@ var ts;
122711
122782
  var host = ts.createCompilerHostWorker(options, /*setParentNodes*/ undefined, system);
122712
122783
  host.createHash = ts.maybeBind(system, system.createHash);
122713
122784
  host.disableUseFileVersionAsSignature = system.disableUseFileVersionAsSignature;
122785
+ host.storeFilesChangingSignatureDuringEmit = system.storeFilesChangingSignatureDuringEmit;
122714
122786
  ts.setGetSourceFileAsHashVersioned(host, system);
122715
122787
  ts.changeCompilerHostLikeToUseCache(host, function (fileName) { return ts.toPath(fileName, host.getCurrentDirectory(), host.getCanonicalFileName); });
122716
122788
  return host;
@@ -131043,7 +131115,7 @@ var ts;
131043
131115
  GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
131044
131116
  GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
131045
131117
  })(GlobalsSearch || (GlobalsSearch = {}));
131046
- function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
131118
+ function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
131047
131119
  var _a, _b, _c;
131048
131120
  var start = ts.timestamp();
131049
131121
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -131058,9 +131130,9 @@ var ts;
131058
131130
  (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete"));
131059
131131
  (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start));
131060
131132
  return result;
131061
- function tryResolve(exportInfo, isFromAmbientModule) {
131133
+ function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
131062
131134
  if (isFromAmbientModule) {
131063
- var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences);
131135
+ var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences);
131064
131136
  if (result_1) {
131065
131137
  ambientCount++;
131066
131138
  }
@@ -131069,7 +131141,7 @@ var ts;
131069
131141
  var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131070
131142
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
131071
131143
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
131072
- ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131144
+ ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131073
131145
  : undefined;
131074
131146
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
131075
131147
  resolutionLimitExceeded = true;
@@ -131174,8 +131246,8 @@ var ts;
131174
131246
  return undefined;
131175
131247
  var lowerCaseTokenText = location.text.toLowerCase();
131176
131248
  var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
131177
- var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences,
131178
- /*isForImportStatementCompletion*/ false, function (context) {
131249
+ var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
131250
+ /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
131179
131251
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
131180
131252
  if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
131181
131253
  // Not an auto import or already resolved; keep as is
@@ -131187,7 +131259,7 @@ var ts;
131187
131259
  }
131188
131260
  var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
131189
131261
  var info = exportMap.get(file.path, entry.data.exportMapKey);
131190
- var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131262
+ var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131191
131263
  if (!result)
131192
131264
  return entry;
131193
131265
  var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
@@ -131779,22 +131851,44 @@ var ts;
131779
131851
  }
131780
131852
  }
131781
131853
  function createSnippetPrinter(printerOptions) {
131854
+ var escapes;
131782
131855
  var baseWriter = ts.textChanges.createWriter(ts.getNewLineCharacter(printerOptions));
131783
131856
  var printer = ts.createPrinter(printerOptions, baseWriter);
131784
- 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)); } });
131857
+ 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); }); } });
131785
131858
  return {
131786
131859
  printSnippetList: printSnippetList,
131787
131860
  printAndFormatSnippetList: printAndFormatSnippetList,
131788
131861
  };
131862
+ // The formatter/scanner will have issues with snippet-escaped text,
131863
+ // so instead of writing the escaped text directly to the writer,
131864
+ // generate a set of changes that can be applied to the unescaped text
131865
+ // to escape it post-formatting.
131866
+ function escapingWrite(s, write) {
131867
+ var escaped = ts.escapeSnippetText(s);
131868
+ if (escaped !== s) {
131869
+ var start = baseWriter.getTextPos();
131870
+ write();
131871
+ var end = baseWriter.getTextPos();
131872
+ escapes = ts.append(escapes || (escapes = []), { newText: escaped, span: { start: start, length: end - start } });
131873
+ }
131874
+ else {
131875
+ write();
131876
+ }
131877
+ }
131789
131878
  /* Snippet-escaping version of `printer.printList`. */
131790
131879
  function printSnippetList(format, list, sourceFile) {
131880
+ var unescaped = printUnescapedSnippetList(format, list, sourceFile);
131881
+ return escapes ? ts.textChanges.applyChanges(unescaped, escapes) : unescaped;
131882
+ }
131883
+ function printUnescapedSnippetList(format, list, sourceFile) {
131884
+ escapes = undefined;
131791
131885
  writer.clear();
131792
131886
  printer.writeList(format, list, sourceFile, writer);
131793
131887
  return writer.getText();
131794
131888
  }
131795
131889
  function printAndFormatSnippetList(format, list, sourceFile, formatContext) {
131796
131890
  var syntheticFile = {
131797
- text: printSnippetList(format, list, sourceFile),
131891
+ text: printUnescapedSnippetList(format, list, sourceFile),
131798
131892
  getLineAndCharacterOfPosition: function (pos) {
131799
131893
  return ts.getLineAndCharacterOfPosition(this, pos);
131800
131894
  },
@@ -131806,7 +131900,10 @@ var ts;
131806
131900
  /* indentation */ 0,
131807
131901
  /* delta */ 0, __assign(__assign({}, formatContext), { options: formatOptions }));
131808
131902
  });
131809
- return ts.textChanges.applyChanges(syntheticFile.text, changes);
131903
+ var allChanges = escapes
131904
+ ? ts.stableSort(ts.concatenate(changes, escapes), function (a, b) { return ts.compareTextSpans(a.span, b.span); })
131905
+ : changes;
131906
+ return ts.textChanges.applyChanges(syntheticFile.text, allChanges);
131810
131907
  }
131811
131908
  }
131812
131909
  function originToCompletionEntryData(origin) {
@@ -132698,7 +132795,7 @@ var ts;
132698
132795
  moduleSymbol: moduleSymbol,
132699
132796
  symbol: firstAccessibleSymbol,
132700
132797
  targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
132701
- }], sourceFile, program, host, preferences) || {}).moduleSpecifier;
132798
+ }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
132702
132799
  if (moduleSpecifier) {
132703
132800
  var origin = {
132704
132801
  kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */),
@@ -132953,7 +133050,7 @@ var ts;
132953
133050
  var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
132954
133051
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
132955
133052
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
132956
- resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
133053
+ resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
132957
133054
  exportInfo.search(sourceFile.path,
132958
133055
  /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
132959
133056
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
@@ -132981,7 +133078,7 @@ var ts;
132981
133078
  }
132982
133079
  // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
132983
133080
  // (We need to ensure that at least one is importable to show a completion.)
132984
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
133081
+ var _a = context.tryResolve(info, symbolName, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
132985
133082
  var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
132986
133083
  var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
132987
133084
  pushAutoImportSymbol(symbol, {
@@ -151805,7 +151902,7 @@ var ts;
151805
151902
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
151806
151903
  var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
151807
151904
  var useRequire = shouldUseRequire(sourceFile, program);
151808
- var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
151905
+ var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
151809
151906
  if (fix) {
151810
151907
  addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
151811
151908
  }
@@ -151975,7 +152072,7 @@ var ts;
151975
152072
  : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
151976
152073
  var useRequire = shouldUseRequire(sourceFile, program);
151977
152074
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
151978
- var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
152075
+ var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, useRequire, host, preferences));
151979
152076
  return {
151980
152077
  moduleSpecifier: fix.moduleSpecifier,
151981
152078
  codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
@@ -151991,10 +152088,10 @@ var ts;
151991
152088
  return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
151992
152089
  }
151993
152090
  codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
151994
- function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152091
+ function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) {
151995
152092
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
151996
152093
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
151997
- return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
152094
+ return getBestFix(getImportFixes(exportInfos, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host);
151998
152095
  }
151999
152096
  function codeFixActionToCodeAction(_a) {
152000
152097
  var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -152049,25 +152146,32 @@ var ts;
152049
152146
  return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
152050
152147
  }
152051
152148
  }
152052
- function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
152053
- var _a = getNewImportFixes(program, importingFile,
152054
- /*position*/ undefined,
152055
- /*isValidTypeOnlyUseSite*/ false,
152056
- /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
152149
+ function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
152150
+ var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
152151
+ /*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
152057
152152
  var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
152058
152153
  return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
152059
152154
  }
152060
152155
  codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
152061
- function getImportFixes(exportInfos, symbolName,
152156
+ function getImportFixes(exportInfos, useNamespaceInfo,
152062
152157
  /** undefined only for missing JSX namespace */
152063
- position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) {
152158
+ isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
152064
152159
  var checker = program.getTypeChecker();
152065
152160
  var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
152066
- var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker);
152161
+ var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
152067
152162
  var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
152068
- // Don't bother providing an action to add a new import if we can add to an existing one.
152069
- var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences);
152070
- return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true);
152163
+ if (addToExisting) {
152164
+ // Don't bother providing an action to add a new import if we can add to an existing one.
152165
+ return {
152166
+ computedWithoutCacheCount: 0,
152167
+ fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), [addToExisting], false),
152168
+ };
152169
+ }
152170
+ 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;
152171
+ return {
152172
+ computedWithoutCacheCount: computedWithoutCacheCount,
152173
+ fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), fixes, true),
152174
+ };
152071
152175
  }
152072
152176
  function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) {
152073
152177
  // It is possible that multiple import statements with the same specifier exist in the file.
@@ -152257,9 +152361,9 @@ var ts;
152257
152361
  });
152258
152362
  return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes };
152259
152363
  }
152260
- function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152364
+ function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) {
152261
152365
  var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); });
152262
- return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
152366
+ return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly);
152263
152367
  }
152264
152368
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
152265
152369
  var _b;
@@ -152355,7 +152459,8 @@ var ts;
152355
152459
  var symbolName = umdSymbol.name;
152356
152460
  var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
152357
152461
  var useRequire = shouldUseRequire(sourceFile, program);
152358
- var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
152462
+ var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined;
152463
+ var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes;
152359
152464
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
152360
152465
  }
152361
152466
  function getUmdSymbol(token, checker) {
@@ -152427,7 +152532,7 @@ var ts;
152427
152532
  var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
152428
152533
  var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
152429
152534
  var _ = _a[0], exportInfos = _a[1];
152430
- return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
152535
+ return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
152431
152536
  }));
152432
152537
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
152433
152538
  }