typescript 4.7.0-dev.20220422 → 4.7.0-dev.20220425

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.20220422";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220425";
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,
@@ -75670,6 +75670,7 @@ var ts;
75670
75670
  // decorators are applied to a declaration by the emitter, and not to an expression.
75671
75671
  var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75672
75672
  var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
75673
+ argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75673
75674
  // The following variables are captured and modified by calls to chooseOverload.
75674
75675
  // If overload resolution or type argument inference fails, we want to report the
75675
75676
  // best error possible. The best error is one which says that an argument was not
@@ -75885,7 +75886,7 @@ var ts;
75885
75886
  // If one or more context sensitive arguments were excluded, we start including
75886
75887
  // them now (and keeping do so for any subsequent candidates) and perform a second
75887
75888
  // round of type inference and applicability checking for this particular candidate.
75888
- argCheckMode = 0 /* Normal */;
75889
+ argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75889
75890
  if (inferenceContext) {
75890
75891
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
75891
75892
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -110514,7 +110515,7 @@ var ts;
110514
110515
  setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined);
110515
110516
  }
110516
110517
  function getCurrentLineMap() {
110517
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
110518
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
110518
110519
  }
110519
110520
  function emit(node, parenthesizerRule) {
110520
110521
  if (node === undefined)
@@ -111689,7 +111690,7 @@ var ts;
111689
111690
  increaseIndent();
111690
111691
  }
111691
111692
  var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */;
111692
- 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 */;
111693
111694
  emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine);
111694
111695
  if (indentedFlag) {
111695
111696
  decreaseIndent();
@@ -112045,7 +112046,7 @@ var ts;
112045
112046
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
112046
112047
  // Emit semicolon in non json files
112047
112048
  // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation)
112048
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112049
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112049
112050
  writeTrailingSemicolon();
112050
112051
  }
112051
112052
  }
@@ -112338,7 +112339,7 @@ var ts;
112338
112339
  if (body.multiLine) {
112339
112340
  return false;
112340
112341
  }
112341
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112342
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112342
112343
  return false;
112343
112344
  }
112344
112345
  if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)
@@ -112363,12 +112364,7 @@ var ts;
112363
112364
  var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
112364
112365
  ? emitBlockFunctionBodyOnSingleLine
112365
112366
  : emitBlockFunctionBodyWorker;
112366
- if (emitBodyWithDetachedComments) {
112367
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112368
- }
112369
- else {
112370
- emitBlockFunctionBody(body);
112371
- }
112367
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112372
112368
  decreaseIndent();
112373
112369
  writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body);
112374
112370
  onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
@@ -112765,7 +112761,8 @@ var ts;
112765
112761
  var emitAsSingleStatement = statements.length === 1 &&
112766
112762
  (
112767
112763
  // treat synthesized nodes as located on the same line for emit purposes
112768
- ts.nodeIsSynthesized(parentNode) ||
112764
+ !currentSourceFile ||
112765
+ ts.nodeIsSynthesized(parentNode) ||
112769
112766
  ts.nodeIsSynthesized(statements[0]) ||
112770
112767
  ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
112771
112768
  var format = 163969 /* CaseOrDefaultClauseStatements */;
@@ -112996,16 +112993,14 @@ var ts;
112996
112993
  function emitSourceFile(node) {
112997
112994
  writeLine();
112998
112995
  var statements = node.statements;
112999
- if (emitBodyWithDetachedComments) {
113000
- // Emit detached comment if there are no prologue directives or if the first node is synthesized.
113001
- // The synthesized node will have no leading comment so some comments may be missed.
113002
- var shouldEmitDetachedComment = statements.length === 0 ||
113003
- !ts.isPrologueDirective(statements[0]) ||
113004
- ts.nodeIsSynthesized(statements[0]);
113005
- if (shouldEmitDetachedComment) {
113006
- emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
113007
- return;
113008
- }
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;
113009
113004
  }
113010
113005
  emitSourceFileWorker(node);
113011
113006
  }
@@ -113394,7 +113389,7 @@ var ts;
113394
113389
  }
113395
113390
  if (isEmpty) {
113396
113391
  // Write a line terminator if the parent node was multi-line
113397
- if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113392
+ if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113398
113393
  writeLine();
113399
113394
  }
113400
113395
  else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) {
@@ -113655,7 +113650,7 @@ var ts;
113655
113650
  }
113656
113651
  var firstChild_1 = children[0];
113657
113652
  if (firstChild_1 === undefined) {
113658
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113653
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113659
113654
  }
113660
113655
  if (firstChild_1.pos === nextListElementPos) {
113661
113656
  // If this child starts at the beginning of a list item in a parent list, its leading
@@ -113679,7 +113674,7 @@ var ts;
113679
113674
  // JsxText will be written with its leading whitespace, so don't add more manually.
113680
113675
  return 0;
113681
113676
  }
113682
- if (parentNode &&
113677
+ if (currentSourceFile && parentNode &&
113683
113678
  !ts.positionIsSynthesized(parentNode.pos) &&
113684
113679
  !ts.nodeIsSynthesized(firstChild_1) &&
113685
113680
  (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -113703,7 +113698,7 @@ var ts;
113703
113698
  // JsxText will be written with its leading whitespace, so don't add more manually.
113704
113699
  return 0;
113705
113700
  }
113706
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113701
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113707
113702
  if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
113708
113703
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
113709
113704
  }
@@ -113735,9 +113730,9 @@ var ts;
113735
113730
  }
113736
113731
  var lastChild = ts.lastOrUndefined(children);
113737
113732
  if (lastChild === undefined) {
113738
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113733
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113739
113734
  }
113740
- 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)) {
113741
113736
  if (preserveSourceNewlines) {
113742
113737
  var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
113743
113738
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -113810,7 +113805,7 @@ var ts;
113810
113805
  if (ts.getStartsOnNewLine(node2)) {
113811
113806
  return 1;
113812
113807
  }
113813
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
113808
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
113814
113809
  if (preserveSourceNewlines) {
113815
113810
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
113816
113811
  }
@@ -113820,7 +113815,7 @@ var ts;
113820
113815
  }
113821
113816
  function isEmptyBlock(block) {
113822
113817
  return block.statements.length === 0
113823
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
113818
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
113824
113819
  }
113825
113820
  function skipSynthesizedParentheses(node) {
113826
113821
  while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) {
@@ -113832,16 +113827,23 @@ var ts;
113832
113827
  if (ts.isGeneratedIdentifier(node)) {
113833
113828
  return generateName(node);
113834
113829
  }
113835
- else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
113836
- return ts.idText(node);
113837
- }
113838
- else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
113830
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
113839
113831
  return getTextOfNode(node.textSourceNode, includeTrivia);
113840
113832
  }
113841
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
113842
- 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
+ }
113843
113845
  }
113844
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
113846
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
113845
113847
  }
113846
113848
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
113847
113849
  if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
@@ -114420,7 +114422,7 @@ var ts;
114420
114422
  return true;
114421
114423
  }
114422
114424
  function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
114423
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114425
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114424
114426
  return;
114425
114427
  if (!hasWrittenComment) {
114426
114428
  ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -114447,7 +114449,7 @@ var ts;
114447
114449
  forEachTrailingCommentToEmit(pos, emitTrailingComment);
114448
114450
  }
114449
114451
  function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114450
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114452
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114451
114453
  return;
114452
114454
  // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
114453
114455
  if (!writer.isAtStartOfLine()) {
@@ -114469,6 +114471,8 @@ var ts;
114469
114471
  exitComment();
114470
114472
  }
114471
114473
  function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
114474
+ if (!currentSourceFile)
114475
+ return;
114472
114476
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114473
114477
  emitPos(commentPos);
114474
114478
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114478,6 +114482,8 @@ var ts;
114478
114482
  }
114479
114483
  }
114480
114484
  function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114485
+ if (!currentSourceFile)
114486
+ return;
114481
114487
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114482
114488
  emitPos(commentPos);
114483
114489
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114510,6 +114516,8 @@ var ts;
114510
114516
  return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
114511
114517
  }
114512
114518
  function forEachLeadingCommentWithoutDetachedComments(cb) {
114519
+ if (!currentSourceFile)
114520
+ return;
114513
114521
  // get the leading comments from detachedPos
114514
114522
  var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
114515
114523
  if (detachedCommentsInfo.length - 1) {
@@ -114521,7 +114529,7 @@ var ts;
114521
114529
  ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos);
114522
114530
  }
114523
114531
  function emitDetachedCommentsAndUpdateCommentsInfo(range) {
114524
- 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);
114525
114533
  if (currentDetachedCommentInfo) {
114526
114534
  if (detachedCommentsInfo) {
114527
114535
  detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -114532,7 +114540,7 @@ var ts;
114532
114540
  }
114533
114541
  }
114534
114542
  function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
114535
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114543
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114536
114544
  return;
114537
114545
  emitPos(commentPos);
114538
114546
  ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
@@ -114544,7 +114552,7 @@ var ts;
114544
114552
  * @return true if the comment is a triple-slash comment else false
114545
114553
  */
114546
114554
  function isTripleSlashComment(commentPos, commentEnd) {
114547
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114555
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114548
114556
  }
114549
114557
  // Source Maps
114550
114558
  function getParsedSourceMap(node) {
@@ -131107,7 +131115,7 @@ var ts;
131107
131115
  GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
131108
131116
  GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
131109
131117
  })(GlobalsSearch || (GlobalsSearch = {}));
131110
- function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
131118
+ function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
131111
131119
  var _a, _b, _c;
131112
131120
  var start = ts.timestamp();
131113
131121
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -131122,9 +131130,9 @@ var ts;
131122
131130
  (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete"));
131123
131131
  (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start));
131124
131132
  return result;
131125
- function tryResolve(exportInfo, isFromAmbientModule) {
131133
+ function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
131126
131134
  if (isFromAmbientModule) {
131127
- 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);
131128
131136
  if (result_1) {
131129
131137
  ambientCount++;
131130
131138
  }
@@ -131133,7 +131141,7 @@ var ts;
131133
131141
  var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131134
131142
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
131135
131143
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
131136
- ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131144
+ ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131137
131145
  : undefined;
131138
131146
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
131139
131147
  resolutionLimitExceeded = true;
@@ -131238,8 +131246,8 @@ var ts;
131238
131246
  return undefined;
131239
131247
  var lowerCaseTokenText = location.text.toLowerCase();
131240
131248
  var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
131241
- var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences,
131242
- /*isForImportStatementCompletion*/ false, function (context) {
131249
+ var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
131250
+ /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
131243
131251
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
131244
131252
  if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
131245
131253
  // Not an auto import or already resolved; keep as is
@@ -131251,7 +131259,7 @@ var ts;
131251
131259
  }
131252
131260
  var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
131253
131261
  var info = exportMap.get(file.path, entry.data.exportMapKey);
131254
- 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)));
131255
131263
  if (!result)
131256
131264
  return entry;
131257
131265
  var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
@@ -132787,7 +132795,7 @@ var ts;
132787
132795
  moduleSymbol: moduleSymbol,
132788
132796
  symbol: firstAccessibleSymbol,
132789
132797
  targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
132790
- }], sourceFile, program, host, preferences) || {}).moduleSpecifier;
132798
+ }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
132791
132799
  if (moduleSpecifier) {
132792
132800
  var origin = {
132793
132801
  kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */),
@@ -133042,7 +133050,7 @@ var ts;
133042
133050
  var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
133043
133051
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
133044
133052
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
133045
- resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
133053
+ resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
133046
133054
  exportInfo.search(sourceFile.path,
133047
133055
  /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
133048
133056
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
@@ -133070,7 +133078,7 @@ var ts;
133070
133078
  }
133071
133079
  // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
133072
133080
  // (We need to ensure that at least one is importable to show a completion.)
133073
- 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;
133074
133082
  var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
133075
133083
  var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
133076
133084
  pushAutoImportSymbol(symbol, {
@@ -151894,7 +151902,7 @@ var ts;
151894
151902
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
151895
151903
  var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
151896
151904
  var useRequire = shouldUseRequire(sourceFile, program);
151897
- 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);
151898
151906
  if (fix) {
151899
151907
  addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
151900
151908
  }
@@ -152064,7 +152072,7 @@ var ts;
152064
152072
  : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
152065
152073
  var useRequire = shouldUseRequire(sourceFile, program);
152066
152074
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
152067
- 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));
152068
152076
  return {
152069
152077
  moduleSpecifier: fix.moduleSpecifier,
152070
152078
  codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
@@ -152080,10 +152088,10 @@ var ts;
152080
152088
  return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
152081
152089
  }
152082
152090
  codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
152083
- function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152091
+ function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152084
152092
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
152085
152093
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
152086
- 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);
152087
152095
  }
152088
152096
  function codeFixActionToCodeAction(_a) {
152089
152097
  var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -152138,25 +152146,32 @@ var ts;
152138
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));
152139
152147
  }
152140
152148
  }
152141
- function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
152142
- var _a = getNewImportFixes(program, importingFile,
152143
- /*position*/ undefined,
152144
- /*isValidTypeOnlyUseSite*/ false,
152145
- /*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;
152146
152152
  var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
152147
152153
  return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
152148
152154
  }
152149
152155
  codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
152150
- function getImportFixes(exportInfos, symbolName,
152156
+ function getImportFixes(exportInfos, useNamespaceInfo,
152151
152157
  /** undefined only for missing JSX namespace */
152152
- position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) {
152158
+ isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
152153
152159
  var checker = program.getTypeChecker();
152154
152160
  var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
152155
- var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker);
152161
+ var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
152156
152162
  var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
152157
- // Don't bother providing an action to add a new import if we can add to an existing one.
152158
- var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences);
152159
- 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
+ };
152160
152175
  }
152161
152176
  function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) {
152162
152177
  // It is possible that multiple import statements with the same specifier exist in the file.
@@ -152346,9 +152361,9 @@ var ts;
152346
152361
  });
152347
152362
  return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes };
152348
152363
  }
152349
- function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152364
+ function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) {
152350
152365
  var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); });
152351
- 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);
152352
152367
  }
152353
152368
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
152354
152369
  var _b;
@@ -152444,7 +152459,8 @@ var ts;
152444
152459
  var symbolName = umdSymbol.name;
152445
152460
  var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
152446
152461
  var useRequire = shouldUseRequire(sourceFile, program);
152447
- 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;
152448
152464
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
152449
152465
  }
152450
152466
  function getUmdSymbol(token, checker) {
@@ -152516,7 +152532,7 @@ var ts;
152516
152532
  var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
152517
152533
  var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
152518
152534
  var _ = _a[0], exportInfos = _a[1];
152519
- 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;
152520
152536
  }));
152521
152537
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
152522
152538
  }