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.
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220422";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220425";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -14896,7 +14896,7 @@ var ts;
14896
14896
  var _a;
14897
14897
  // If we don't need to downlevel and we can reach the original source text using
14898
14898
  // the node's parent reference, then simply get the text as it was originally written.
14899
- if (canUseOriginalText(node, flags)) {
14899
+ if (sourceFile && canUseOriginalText(node, flags)) {
14900
14900
  return getSourceTextOfNodeFromSourceFile(sourceFile, node);
14901
14901
  }
14902
14902
  // If we can't reach the original source text, use the canonical form if it's a number,
@@ -75864,6 +75864,7 @@ var ts;
75864
75864
  // decorators are applied to a declaration by the emitter, and not to an expression.
75865
75865
  var isSingleNonGenericCandidate = candidates.length === 1 && !candidates[0].typeParameters;
75866
75866
  var argCheckMode = !isDecorator && !isSingleNonGenericCandidate && ts.some(args, isContextSensitive) ? 4 /* SkipContextSensitive */ : 0 /* Normal */;
75867
+ argCheckMode |= checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
75867
75868
  // The following variables are captured and modified by calls to chooseOverload.
75868
75869
  // If overload resolution or type argument inference fails, we want to report the
75869
75870
  // best error possible. The best error is one which says that an argument was not
@@ -76079,7 +76080,7 @@ var ts;
76079
76080
  // If one or more context sensitive arguments were excluded, we start including
76080
76081
  // them now (and keeping do so for any subsequent candidates) and perform a second
76081
76082
  // round of type inference and applicability checking for this particular candidate.
76082
- argCheckMode = 0 /* Normal */;
76083
+ argCheckMode = checkMode & 32 /* IsForStringLiteralArgumentCompletions */;
76083
76084
  if (inferenceContext) {
76084
76085
  var typeArgumentTypes = inferTypeArguments(node, candidate, args, argCheckMode, inferenceContext);
76085
76086
  checkCandidate = getSignatureInstantiation(candidate, typeArgumentTypes, ts.isInJSFile(candidate.declaration), inferenceContext && inferenceContext.inferredTypeParameters);
@@ -110708,7 +110709,7 @@ var ts;
110708
110709
  setWriter(/*output*/ undefined, /*_sourceMapGenerator*/ undefined);
110709
110710
  }
110710
110711
  function getCurrentLineMap() {
110711
- return currentLineMap || (currentLineMap = ts.getLineStarts(currentSourceFile));
110712
+ return currentLineMap || (currentLineMap = ts.getLineStarts(ts.Debug.checkDefined(currentSourceFile)));
110712
110713
  }
110713
110714
  function emit(node, parenthesizerRule) {
110714
110715
  if (node === undefined)
@@ -111883,7 +111884,7 @@ var ts;
111883
111884
  increaseIndent();
111884
111885
  }
111885
111886
  var preferNewLine = node.multiLine ? 65536 /* PreferNewLine */ : 0 /* None */;
111886
- var allowTrailingComma = currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */;
111887
+ var allowTrailingComma = currentSourceFile && currentSourceFile.languageVersion >= 1 /* ES5 */ && !ts.isJsonSourceFile(currentSourceFile) ? 64 /* AllowTrailingComma */ : 0 /* None */;
111887
111888
  emitList(node, node.properties, 526226 /* ObjectLiteralExpressionProperties */ | allowTrailingComma | preferNewLine);
111888
111889
  if (indentedFlag) {
111889
111890
  decreaseIndent();
@@ -112239,7 +112240,7 @@ var ts;
112239
112240
  emitExpression(node.expression, parenthesizer.parenthesizeExpressionOfExpressionStatement);
112240
112241
  // Emit semicolon in non json files
112241
112242
  // or if json file that created synthesized expression(eg.define expression statement when --out and amd code generation)
112242
- if (!ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112243
+ if (!currentSourceFile || !ts.isJsonSourceFile(currentSourceFile) || ts.nodeIsSynthesized(node.expression)) {
112243
112244
  writeTrailingSemicolon();
112244
112245
  }
112245
112246
  }
@@ -112532,7 +112533,7 @@ var ts;
112532
112533
  if (body.multiLine) {
112533
112534
  return false;
112534
112535
  }
112535
- if (!ts.nodeIsSynthesized(body) && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112536
+ if (!ts.nodeIsSynthesized(body) && currentSourceFile && !ts.rangeIsOnSingleLine(body, currentSourceFile)) {
112536
112537
  return false;
112537
112538
  }
112538
112539
  if (getLeadingLineTerminatorCount(body, body.statements, 2 /* PreserveLines */)
@@ -112557,12 +112558,7 @@ var ts;
112557
112558
  var emitBlockFunctionBody = shouldEmitBlockFunctionBodyOnSingleLine(body)
112558
112559
  ? emitBlockFunctionBodyOnSingleLine
112559
112560
  : emitBlockFunctionBodyWorker;
112560
- if (emitBodyWithDetachedComments) {
112561
- emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112562
- }
112563
- else {
112564
- emitBlockFunctionBody(body);
112565
- }
112561
+ emitBodyWithDetachedComments(body, body.statements, emitBlockFunctionBody);
112566
112562
  decreaseIndent();
112567
112563
  writeToken(19 /* CloseBraceToken */, body.statements.end, writePunctuation, body);
112568
112564
  onAfterEmitNode === null || onAfterEmitNode === void 0 ? void 0 : onAfterEmitNode(body);
@@ -112959,7 +112955,8 @@ var ts;
112959
112955
  var emitAsSingleStatement = statements.length === 1 &&
112960
112956
  (
112961
112957
  // treat synthesized nodes as located on the same line for emit purposes
112962
- ts.nodeIsSynthesized(parentNode) ||
112958
+ !currentSourceFile ||
112959
+ ts.nodeIsSynthesized(parentNode) ||
112963
112960
  ts.nodeIsSynthesized(statements[0]) ||
112964
112961
  ts.rangeStartPositionsAreOnSameLine(parentNode, statements[0], currentSourceFile));
112965
112962
  var format = 163969 /* CaseOrDefaultClauseStatements */;
@@ -113190,16 +113187,14 @@ var ts;
113190
113187
  function emitSourceFile(node) {
113191
113188
  writeLine();
113192
113189
  var statements = node.statements;
113193
- if (emitBodyWithDetachedComments) {
113194
- // Emit detached comment if there are no prologue directives or if the first node is synthesized.
113195
- // The synthesized node will have no leading comment so some comments may be missed.
113196
- var shouldEmitDetachedComment = statements.length === 0 ||
113197
- !ts.isPrologueDirective(statements[0]) ||
113198
- ts.nodeIsSynthesized(statements[0]);
113199
- if (shouldEmitDetachedComment) {
113200
- emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
113201
- return;
113202
- }
113190
+ // Emit detached comment if there are no prologue directives or if the first node is synthesized.
113191
+ // The synthesized node will have no leading comment so some comments may be missed.
113192
+ var shouldEmitDetachedComment = statements.length === 0 ||
113193
+ !ts.isPrologueDirective(statements[0]) ||
113194
+ ts.nodeIsSynthesized(statements[0]);
113195
+ if (shouldEmitDetachedComment) {
113196
+ emitBodyWithDetachedComments(node, statements, emitSourceFileWorker);
113197
+ return;
113203
113198
  }
113204
113199
  emitSourceFileWorker(node);
113205
113200
  }
@@ -113588,7 +113583,7 @@ var ts;
113588
113583
  }
113589
113584
  if (isEmpty) {
113590
113585
  // Write a line terminator if the parent node was multi-line
113591
- if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113586
+ if (format & 1 /* MultiLine */ && !(preserveSourceNewlines && (!parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile)))) {
113592
113587
  writeLine();
113593
113588
  }
113594
113589
  else if (format & 256 /* SpaceBetweenBraces */ && !(format & 524288 /* NoSpaceIfEmpty */)) {
@@ -113849,7 +113844,7 @@ var ts;
113849
113844
  }
113850
113845
  var firstChild_1 = children[0];
113851
113846
  if (firstChild_1 === undefined) {
113852
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113847
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113853
113848
  }
113854
113849
  if (firstChild_1.pos === nextListElementPos) {
113855
113850
  // If this child starts at the beginning of a list item in a parent list, its leading
@@ -113873,7 +113868,7 @@ var ts;
113873
113868
  // JsxText will be written with its leading whitespace, so don't add more manually.
113874
113869
  return 0;
113875
113870
  }
113876
- if (parentNode &&
113871
+ if (currentSourceFile && parentNode &&
113877
113872
  !ts.positionIsSynthesized(parentNode.pos) &&
113878
113873
  !ts.nodeIsSynthesized(firstChild_1) &&
113879
113874
  (!firstChild_1.parent || ts.getOriginalNode(firstChild_1.parent) === ts.getOriginalNode(parentNode))) {
@@ -113897,7 +113892,7 @@ var ts;
113897
113892
  // JsxText will be written with its leading whitespace, so don't add more manually.
113898
113893
  return 0;
113899
113894
  }
113900
- else if (!ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113895
+ else if (currentSourceFile && !ts.nodeIsSynthesized(previousNode) && !ts.nodeIsSynthesized(nextNode)) {
113901
113896
  if (preserveSourceNewlines && siblingNodePositionsAreComparable(previousNode, nextNode)) {
113902
113897
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(previousNode, nextNode, currentSourceFile, includeComments); });
113903
113898
  }
@@ -113929,9 +113924,9 @@ var ts;
113929
113924
  }
113930
113925
  var lastChild = ts.lastOrUndefined(children);
113931
113926
  if (lastChild === undefined) {
113932
- return !parentNode || ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113927
+ return !parentNode || currentSourceFile && ts.rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1;
113933
113928
  }
113934
- if (parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
113929
+ if (currentSourceFile && parentNode && !ts.positionIsSynthesized(parentNode.pos) && !ts.nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) {
113935
113930
  if (preserveSourceNewlines) {
113936
113931
  var end_1 = ts.isNodeArray(children) && !ts.positionIsSynthesized(children.end) ? children.end : lastChild.end;
113937
113932
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenPositionAndNextNonWhitespaceCharacter(end_1, parentNode.end, currentSourceFile, includeComments); });
@@ -114004,7 +113999,7 @@ var ts;
114004
113999
  if (ts.getStartsOnNewLine(node2)) {
114005
114000
  return 1;
114006
114001
  }
114007
- if (!ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
114002
+ if (currentSourceFile && !ts.nodeIsSynthesized(parent) && !ts.nodeIsSynthesized(node1) && !ts.nodeIsSynthesized(node2)) {
114008
114003
  if (preserveSourceNewlines) {
114009
114004
  return getEffectiveLines(function (includeComments) { return ts.getLinesBetweenRangeEndAndRangeStart(node1, node2, currentSourceFile, includeComments); });
114010
114005
  }
@@ -114014,7 +114009,7 @@ var ts;
114014
114009
  }
114015
114010
  function isEmptyBlock(block) {
114016
114011
  return block.statements.length === 0
114017
- && ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile);
114012
+ && (!currentSourceFile || ts.rangeEndIsOnSameLineAsRangeStart(block, block, currentSourceFile));
114018
114013
  }
114019
114014
  function skipSynthesizedParentheses(node) {
114020
114015
  while (node.kind === 212 /* ParenthesizedExpression */ && ts.nodeIsSynthesized(node)) {
@@ -114026,16 +114021,23 @@ var ts;
114026
114021
  if (ts.isGeneratedIdentifier(node)) {
114027
114022
  return generateName(node);
114028
114023
  }
114029
- else if ((ts.isIdentifier(node) || ts.isPrivateIdentifier(node)) && (ts.nodeIsSynthesized(node) || !node.parent || !currentSourceFile || (node.parent && currentSourceFile && ts.getSourceFileOfNode(node) !== ts.getOriginalNode(currentSourceFile)))) {
114030
- return ts.idText(node);
114031
- }
114032
- else if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
114024
+ if (ts.isStringLiteral(node) && node.textSourceNode) {
114033
114025
  return getTextOfNode(node.textSourceNode, includeTrivia);
114034
114026
  }
114035
- else if (ts.isLiteralExpression(node) && (ts.nodeIsSynthesized(node) || !node.parent)) {
114036
- return node.text;
114027
+ var sourceFile = currentSourceFile; // const needed for control flow
114028
+ var canUseSourceFile = !!sourceFile && !!node.parent && !ts.nodeIsSynthesized(node);
114029
+ if (ts.isMemberName(node)) {
114030
+ if (!canUseSourceFile || ts.getSourceFileOfNode(node) !== ts.getOriginalNode(sourceFile)) {
114031
+ return ts.idText(node);
114032
+ }
114033
+ }
114034
+ else {
114035
+ ts.Debug.assertNode(node, ts.isLiteralExpression); // not strictly necessary
114036
+ if (!canUseSourceFile) {
114037
+ return node.text;
114038
+ }
114037
114039
  }
114038
- return ts.getSourceTextOfNodeFromSourceFile(currentSourceFile, node, includeTrivia);
114040
+ return ts.getSourceTextOfNodeFromSourceFile(sourceFile, node, includeTrivia);
114039
114041
  }
114040
114042
  function getLiteralTextOfNode(node, neverAsciiEscape, jsxAttributeEscape) {
114041
114043
  if (node.kind === 10 /* StringLiteral */ && node.textSourceNode) {
@@ -114614,7 +114616,7 @@ var ts;
114614
114616
  return true;
114615
114617
  }
114616
114618
  function emitLeadingComment(commentPos, commentEnd, kind, hasTrailingNewLine, rangePos) {
114617
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114619
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114618
114620
  return;
114619
114621
  if (!hasWrittenComment) {
114620
114622
  ts.emitNewLineBeforeLeadingCommentOfPosition(getCurrentLineMap(), writer, rangePos, commentPos);
@@ -114641,7 +114643,7 @@ var ts;
114641
114643
  forEachTrailingCommentToEmit(pos, emitTrailingComment);
114642
114644
  }
114643
114645
  function emitTrailingComment(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114644
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114646
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114645
114647
  return;
114646
114648
  // trailing comments are emitted at space/*trailing comment1 */space/*trailing comment2*/
114647
114649
  if (!writer.isAtStartOfLine()) {
@@ -114663,6 +114665,8 @@ var ts;
114663
114665
  exitComment();
114664
114666
  }
114665
114667
  function emitTrailingCommentOfPositionNoNewline(commentPos, commentEnd, kind) {
114668
+ if (!currentSourceFile)
114669
+ return;
114666
114670
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114667
114671
  emitPos(commentPos);
114668
114672
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114672,6 +114676,8 @@ var ts;
114672
114676
  }
114673
114677
  }
114674
114678
  function emitTrailingCommentOfPosition(commentPos, commentEnd, _kind, hasTrailingNewLine) {
114679
+ if (!currentSourceFile)
114680
+ return;
114675
114681
  // trailing comments of a position are emitted at /*trailing comment1 */space/*trailing comment*/space
114676
114682
  emitPos(commentPos);
114677
114683
  ts.writeCommentRange(currentSourceFile.text, getCurrentLineMap(), writer, commentPos, commentEnd, newLine);
@@ -114704,6 +114710,8 @@ var ts;
114704
114710
  return detachedCommentsInfo !== undefined && ts.last(detachedCommentsInfo).nodePos === pos;
114705
114711
  }
114706
114712
  function forEachLeadingCommentWithoutDetachedComments(cb) {
114713
+ if (!currentSourceFile)
114714
+ return;
114707
114715
  // get the leading comments from detachedPos
114708
114716
  var pos = ts.last(detachedCommentsInfo).detachedCommentEndPos;
114709
114717
  if (detachedCommentsInfo.length - 1) {
@@ -114715,7 +114723,7 @@ var ts;
114715
114723
  ts.forEachLeadingCommentRange(currentSourceFile.text, pos, cb, /*state*/ pos);
114716
114724
  }
114717
114725
  function emitDetachedCommentsAndUpdateCommentsInfo(range) {
114718
- var currentDetachedCommentInfo = ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
114726
+ var currentDetachedCommentInfo = currentSourceFile && ts.emitDetachedComments(currentSourceFile.text, getCurrentLineMap(), writer, emitComment, range, newLine, commentsDisabled);
114719
114727
  if (currentDetachedCommentInfo) {
114720
114728
  if (detachedCommentsInfo) {
114721
114729
  detachedCommentsInfo.push(currentDetachedCommentInfo);
@@ -114726,7 +114734,7 @@ var ts;
114726
114734
  }
114727
114735
  }
114728
114736
  function emitComment(text, lineMap, writer, commentPos, commentEnd, newLine) {
114729
- if (!shouldWriteComment(currentSourceFile.text, commentPos))
114737
+ if (!currentSourceFile || !shouldWriteComment(currentSourceFile.text, commentPos))
114730
114738
  return;
114731
114739
  emitPos(commentPos);
114732
114740
  ts.writeCommentRange(text, lineMap, writer, commentPos, commentEnd, newLine);
@@ -114738,7 +114746,7 @@ var ts;
114738
114746
  * @return true if the comment is a triple-slash comment else false
114739
114747
  */
114740
114748
  function isTripleSlashComment(commentPos, commentEnd) {
114741
- return ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114749
+ return !!currentSourceFile && ts.isRecognizedTripleSlashComment(currentSourceFile.text, commentPos, commentEnd);
114742
114750
  }
114743
114751
  // Source Maps
114744
114752
  function getParsedSourceMap(node) {
@@ -131718,7 +131726,7 @@ var ts;
131718
131726
  GlobalsSearch[GlobalsSearch["Success"] = 1] = "Success";
131719
131727
  GlobalsSearch[GlobalsSearch["Fail"] = 2] = "Fail";
131720
131728
  })(GlobalsSearch || (GlobalsSearch = {}));
131721
- function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, preferences, isForImportStatementCompletion, cb) {
131729
+ function resolvingModuleSpecifiers(logPrefix, host, program, sourceFile, position, preferences, isForImportStatementCompletion, isValidTypeOnlyUseSite, cb) {
131722
131730
  var _a, _b, _c;
131723
131731
  var start = ts.timestamp();
131724
131732
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -131733,9 +131741,9 @@ var ts;
131733
131741
  (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, logPrefix + ": response is " + (resolutionLimitExceeded ? "incomplete" : "complete"));
131734
131742
  (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, logPrefix + ": " + (ts.timestamp() - start));
131735
131743
  return result;
131736
- function tryResolve(exportInfo, isFromAmbientModule) {
131744
+ function tryResolve(exportInfo, symbolName, isFromAmbientModule) {
131737
131745
  if (isFromAmbientModule) {
131738
- var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences);
131746
+ var result_1 = ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences);
131739
131747
  if (result_1) {
131740
131748
  ambientCount++;
131741
131749
  }
@@ -131744,7 +131752,7 @@ var ts;
131744
131752
  var shouldResolveModuleSpecifier = isForImportStatementCompletion || preferences.allowIncompleteCompletions && resolvedCount < Completions.moduleSpecifierResolutionLimit;
131745
131753
  var shouldGetModuleSpecifierFromCache = !shouldResolveModuleSpecifier && preferences.allowIncompleteCompletions && cacheAttemptCount < Completions.moduleSpecifierResolutionCacheAttemptLimit;
131746
131754
  var result = (shouldResolveModuleSpecifier || shouldGetModuleSpecifierFromCache)
131747
- ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131755
+ ? ts.codefix.getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, sourceFile, program, host, preferences, packageJsonImportFilter, shouldGetModuleSpecifierFromCache)
131748
131756
  : undefined;
131749
131757
  if (!shouldResolveModuleSpecifier && !shouldGetModuleSpecifierFromCache || shouldGetModuleSpecifierFromCache && !result) {
131750
131758
  resolutionLimitExceeded = true;
@@ -131849,8 +131857,8 @@ var ts;
131849
131857
  return undefined;
131850
131858
  var lowerCaseTokenText = location.text.toLowerCase();
131851
131859
  var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
131852
- var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences,
131853
- /*isForImportStatementCompletion*/ false, function (context) {
131860
+ var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, location.getStart(), preferences,
131861
+ /*isForImportStatementCompletion*/ false, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
131854
131862
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
131855
131863
  if (!entry.hasAction || !entry.source || !entry.data || completionEntryDataIsResolved(entry.data)) {
131856
131864
  // Not an auto import or already resolved; keep as is
@@ -131862,7 +131870,7 @@ var ts;
131862
131870
  }
131863
131871
  var origin = ts.Debug.checkDefined(getAutoImportSymbolFromCompletionEntryData(entry.name, entry.data, program, host)).origin;
131864
131872
  var info = exportMap.get(file.path, entry.data.exportMapKey);
131865
- var result = info && context.tryResolve(info, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131873
+ var result = info && context.tryResolve(info, entry.name, !ts.isExternalModuleNameRelative(ts.stripQuotes(origin.moduleSymbol.name)));
131866
131874
  if (!result)
131867
131875
  return entry;
131868
131876
  var newOrigin = __assign(__assign({}, origin), { kind: 32 /* ResolvedExport */, moduleSpecifier: result.moduleSpecifier });
@@ -133398,7 +133406,7 @@ var ts;
133398
133406
  moduleSymbol: moduleSymbol,
133399
133407
  symbol: firstAccessibleSymbol,
133400
133408
  targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
133401
- }], sourceFile, program, host, preferences) || {}).moduleSpecifier;
133409
+ }], firstAccessibleSymbol.name, position, ts.isValidTypeOnlyAliasUseSite(location), sourceFile, program, host, preferences) || {}).moduleSpecifier;
133402
133410
  if (moduleSpecifier) {
133403
133411
  var origin = {
133404
133412
  kind: getNullableSymbolOriginInfoKind(6 /* SymbolMemberExport */),
@@ -133653,7 +133661,7 @@ var ts;
133653
133661
  var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
133654
133662
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
133655
133663
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
133656
- resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
133664
+ resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, position, preferences, !!importCompletionNode, ts.isValidTypeOnlyAliasUseSite(location), function (context) {
133657
133665
  exportInfo.search(sourceFile.path,
133658
133666
  /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
133659
133667
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
@@ -133681,7 +133689,7 @@ var ts;
133681
133689
  }
133682
133690
  // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
133683
133691
  // (We need to ensure that at least one is importable to show a completion.)
133684
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
133692
+ var _a = context.tryResolve(info, symbolName, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
133685
133693
  var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
133686
133694
  var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
133687
133695
  pushAutoImportSymbol(symbol, {
@@ -152505,7 +152513,7 @@ var ts;
152505
152513
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
152506
152514
  var exportInfo = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
152507
152515
  var useRequire = shouldUseRequire(sourceFile, program);
152508
- var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
152516
+ var fix = getImportFixForSymbol(sourceFile, exportInfo, moduleSymbol, program, /*useNamespaceInfo*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
152509
152517
  if (fix) {
152510
152518
  addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
152511
152519
  }
@@ -152675,7 +152683,7 @@ var ts;
152675
152683
  : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
152676
152684
  var useRequire = shouldUseRequire(sourceFile, program);
152677
152685
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
152678
- var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
152686
+ var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite, useRequire, host, preferences));
152679
152687
  return {
152680
152688
  moduleSpecifier: fix.moduleSpecifier,
152681
152689
  codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
@@ -152691,10 +152699,10 @@ var ts;
152691
152699
  return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
152692
152700
  }
152693
152701
  codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
152694
- function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152702
+ function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, program, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152695
152703
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
152696
152704
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
152697
- return getBestFix(getImportFixes(exportInfos, symbolName, position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences), sourceFile, program, packageJsonImportFilter, host);
152705
+ return getBestFix(getImportFixes(exportInfos, useNamespaceInfo, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes, sourceFile, program, packageJsonImportFilter, host);
152698
152706
  }
152699
152707
  function codeFixActionToCodeAction(_a) {
152700
152708
  var description = _a.description, changes = _a.changes, commands = _a.commands;
@@ -152749,25 +152757,32 @@ var ts;
152749
152757
  return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
152750
152758
  }
152751
152759
  }
152752
- function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
152753
- var _a = getNewImportFixes(program, importingFile,
152754
- /*position*/ undefined,
152755
- /*isValidTypeOnlyUseSite*/ false,
152756
- /*useRequire*/ false, exportInfo, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
152760
+ function getModuleSpecifierForBestExportInfo(exportInfo, symbolName, position, isValidTypeOnlyUseSite, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
152761
+ var _a = getImportFixes(exportInfo, { symbolName: symbolName, position: position }, isValidTypeOnlyUseSite,
152762
+ /*useRequire*/ false, program, importingFile, host, preferences, fromCacheOnly), fixes = _a.fixes, computedWithoutCacheCount = _a.computedWithoutCacheCount;
152757
152763
  var result = getBestFix(fixes, importingFile, program, packageJsonImportFilter || ts.createPackageJsonImportFilter(importingFile, preferences, host), host);
152758
152764
  return result && __assign(__assign({}, result), { computedWithoutCacheCount: computedWithoutCacheCount });
152759
152765
  }
152760
152766
  codefix.getModuleSpecifierForBestExportInfo = getModuleSpecifierForBestExportInfo;
152761
- function getImportFixes(exportInfos, symbolName,
152767
+ function getImportFixes(exportInfos, useNamespaceInfo,
152762
152768
  /** undefined only for missing JSX namespace */
152763
- position, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences) {
152769
+ isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences, fromCacheOnly) {
152764
152770
  var checker = program.getTypeChecker();
152765
152771
  var existingImports = ts.flatMap(exportInfos, function (info) { return getExistingImportDeclarations(info, checker, sourceFile, program.getCompilerOptions()); });
152766
- var useNamespace = position === undefined ? undefined : tryUseExistingNamespaceImport(existingImports, symbolName, position, checker);
152772
+ var useNamespace = useNamespaceInfo && tryUseExistingNamespaceImport(existingImports, useNamespaceInfo.symbolName, useNamespaceInfo.position, checker);
152767
152773
  var addToExisting = tryAddToExistingImport(existingImports, isValidTypeOnlyUseSite, checker, program.getCompilerOptions());
152768
- // Don't bother providing an action to add a new import if we can add to an existing one.
152769
- var addImport = addToExisting ? [addToExisting] : getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences);
152770
- return __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), addImport, true);
152774
+ if (addToExisting) {
152775
+ // Don't bother providing an action to add a new import if we can add to an existing one.
152776
+ return {
152777
+ computedWithoutCacheCount: 0,
152778
+ fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), [addToExisting], false),
152779
+ };
152780
+ }
152781
+ 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;
152782
+ return {
152783
+ computedWithoutCacheCount: computedWithoutCacheCount,
152784
+ fixes: __spreadArray(__spreadArray([], (useNamespace ? [useNamespace] : ts.emptyArray), true), fixes, true),
152785
+ };
152771
152786
  }
152772
152787
  function tryUseExistingNamespaceImport(existingImports, symbolName, position, checker) {
152773
152788
  // It is possible that multiple import statements with the same specifier exist in the file.
@@ -152957,9 +152972,9 @@ var ts;
152957
152972
  });
152958
152973
  return { computedWithoutCacheCount: computedWithoutCacheCount, fixes: fixes };
152959
152974
  }
152960
- function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
152975
+ function getFixesForAddImport(exportInfos, existingImports, program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, host, preferences, fromCacheOnly) {
152961
152976
  var existingDeclaration = ts.firstDefined(existingImports, function (info) { return newImportInfoFromExistingSpecifier(info, isValidTypeOnlyUseSite, useRequire, program.getTypeChecker(), program.getCompilerOptions()); });
152962
- return existingDeclaration ? [existingDeclaration] : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences).fixes;
152977
+ return existingDeclaration ? { fixes: [existingDeclaration] } : getNewImportFixes(program, sourceFile, position, isValidTypeOnlyUseSite, useRequire, exportInfos, host, preferences, fromCacheOnly);
152963
152978
  }
152964
152979
  function newImportInfoFromExistingSpecifier(_a, isValidTypeOnlyUseSite, useRequire, checker, compilerOptions) {
152965
152980
  var _b;
@@ -153055,7 +153070,8 @@ var ts;
153055
153070
  var symbolName = umdSymbol.name;
153056
153071
  var exportInfo = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
153057
153072
  var useRequire = shouldUseRequire(sourceFile, program);
153058
- var fixes = getImportFixes(exportInfo, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
153073
+ var position = ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined;
153074
+ var fixes = getImportFixes(exportInfo, position ? { position: position, symbolName: symbolName } : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences).fixes;
153059
153075
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
153060
153076
  }
153061
153077
  function getUmdSymbol(token, checker) {
@@ -153127,7 +153143,7 @@ var ts;
153127
153143
  var exportInfo = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
153128
153144
  var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfo.entries(), function (_a) {
153129
153145
  var _ = _a[0], exportInfos = _a[1];
153130
- return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
153146
+ return getImportFixes(exportInfos, { symbolName: symbolName, position: symbolToken.getStart(sourceFile) }, isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences).fixes;
153131
153147
  }));
153132
153148
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
153133
153149
  }