typescript 4.6.0-dev.20220126 → 4.6.0-dev.20220127

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.20220126";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220127";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -9473,6 +9473,8 @@ var ts;
9473
9473
  Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
9474
9474
  Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
9475
9475
  Includes_imports_of_types_referenced_by_0: diag(90054, ts.DiagnosticCategory.Message, "Includes_imports_of_types_referenced_by_0_90054", "Includes imports of types referenced by '{0}'"),
9476
+ Remove_type_from_import_declaration_from_0: diag(90055, ts.DiagnosticCategory.Message, "Remove_type_from_import_declaration_from_0_90055", "Remove 'type' from import declaration from \"{0}\""),
9477
+ Remove_type_from_import_of_0_from_1: diag(90056, ts.DiagnosticCategory.Message, "Remove_type_from_import_of_0_from_1_90056", "Remove 'type' from import of '{0}' from \"{1}\""),
9476
9478
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9477
9479
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9478
9480
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -14902,6 +14904,15 @@ var ts;
14902
14904
  };
14903
14905
  }
14904
14906
  ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain;
14907
+ function createDiagnosticMessageChainFromDiagnostic(diagnostic) {
14908
+ return typeof diagnostic.messageText === "string" ? {
14909
+ code: diagnostic.code,
14910
+ category: diagnostic.category,
14911
+ messageText: diagnostic.messageText,
14912
+ next: diagnostic.next,
14913
+ } : diagnostic.messageText;
14914
+ }
14915
+ ts.createDiagnosticMessageChainFromDiagnostic = createDiagnosticMessageChainFromDiagnostic;
14905
14916
  function createDiagnosticForRange(sourceFile, range, message) {
14906
14917
  return {
14907
14918
  file: sourceFile,
@@ -52535,7 +52546,8 @@ var ts;
52535
52546
  includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
52536
52547
  }
52537
52548
  if (ts.isIdentifier(node)) {
52538
- var name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.factory.cloneNode(node);
52549
+ var type = getDeclaredTypeOfSymbol(sym);
52550
+ var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
52539
52551
  name.symbol = sym; // for quickinfo, which uses identifier symbol information
52540
52552
  return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
52541
52553
  }
@@ -74427,7 +74439,7 @@ var ts;
74427
74439
  }
74428
74440
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
74429
74441
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
74430
- var chain = ts.chainDiagnosticMessages(ts.map(diags_3, function (d) { return typeof d.messageText === "string" ? d : d.messageText; }), ts.Diagnostics.No_overload_matches_this_call);
74442
+ var chain = ts.chainDiagnosticMessages(ts.map(diags_3, ts.createDiagnosticMessageChainFromDiagnostic), ts.Diagnostics.No_overload_matches_this_call);
74431
74443
  // The below is a spread to guarantee we get a new (mutable) array - our `flatMap` helper tries to do "smart" optimizations where it reuses input
74432
74444
  // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic
74433
74445
  var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; }), true);
@@ -82806,16 +82818,15 @@ var ts;
82806
82818
  return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
82807
82819
  case 206 /* ElementAccessExpression */:
82808
82820
  case 205 /* PropertyAccessExpression */:
82809
- var ex = expr;
82810
- if (isConstantMemberAccess(ex)) {
82811
- var type = getTypeOfExpression(ex.expression);
82821
+ if (isConstantMemberAccess(expr)) {
82822
+ var type = getTypeOfExpression(expr.expression);
82812
82823
  if (type.symbol && type.symbol.flags & 384 /* Enum */) {
82813
82824
  var name = void 0;
82814
- if (ex.kind === 205 /* PropertyAccessExpression */) {
82815
- name = ex.name.escapedText;
82825
+ if (expr.kind === 205 /* PropertyAccessExpression */) {
82826
+ name = expr.name.escapedText;
82816
82827
  }
82817
82828
  else {
82818
- name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
82829
+ name = ts.escapeLeadingUnderscores(ts.cast(expr.argumentExpression, ts.isLiteralExpression).text);
82819
82830
  }
82820
82831
  return evaluateEnumMember(expr, type.symbol, name);
82821
82832
  }
@@ -82843,6 +82854,10 @@ var ts;
82843
82854
  }
82844
82855
  }
82845
82856
  function isConstantMemberAccess(node) {
82857
+ var type = getTypeOfExpression(node);
82858
+ if (type === errorType) {
82859
+ return false;
82860
+ }
82846
82861
  return node.kind === 79 /* Identifier */ ||
82847
82862
  node.kind === 205 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) ||
82848
82863
  node.kind === 206 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) &&
@@ -126556,11 +126571,11 @@ var ts;
126556
126571
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
126557
126572
  }
126558
126573
  ts.firstOrOnly = firstOrOnly;
126559
- function getNameForExportedSymbol(symbol, scriptTarget) {
126574
+ function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
126560
126575
  if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
126561
126576
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
126562
126577
  return ts.firstDefined(symbol.declarations, function (d) { var _a; return ts.isExportAssignment(d) ? (_a = ts.tryCast(ts.skipOuterExpressions(d.expression), ts.isIdentifier)) === null || _a === void 0 ? void 0 : _a.text : undefined; })
126563
- || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
126578
+ || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
126564
126579
  }
126565
126580
  return symbol.name;
126566
126581
  }
@@ -126688,7 +126703,7 @@ var ts;
126688
126703
  symbols.clear();
126689
126704
  usableByFileName = undefined;
126690
126705
  },
126691
- add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, scriptTarget, checker) {
126706
+ add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, checker) {
126692
126707
  if (importingFile !== usableByFileName) {
126693
126708
  cache.clear();
126694
126709
  usableByFileName = importingFile;
@@ -126704,7 +126719,7 @@ var ts;
126704
126719
  // get a better name.
126705
126720
  var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126706
126721
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
126707
- : ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
126722
+ : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
126708
126723
  var moduleName = ts.stripQuotes(moduleSymbol.name);
126709
126724
  var id = exportInfoId++;
126710
126725
  var target = ts.skipAlias(symbol, checker);
@@ -126737,7 +126752,14 @@ var ts;
126737
126752
  return;
126738
126753
  exportInfo.forEach(function (info, key) {
126739
126754
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
126740
- action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName, key);
126755
+ var rehydrated = info.map(rehydrateCachedInfo);
126756
+ action(rehydrated, function (preferCapitalized) {
126757
+ var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
126758
+ var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126759
+ return preferCapitalized
126760
+ ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
126761
+ : symbolName;
126762
+ }, !!ambientModuleName, key);
126741
126763
  });
126742
126764
  },
126743
126765
  releaseSymbols: function () {
@@ -126919,7 +126941,6 @@ var ts;
126919
126941
  }
126920
126942
  (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
126921
126943
  var compilerOptions = program.getCompilerOptions();
126922
- var scriptTarget = ts.getEmitScriptTarget(compilerOptions);
126923
126944
  var moduleCount = 0;
126924
126945
  forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
126925
126946
  if (++moduleCount % 100 === 0)
@@ -126930,11 +126951,11 @@ var ts;
126930
126951
  // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
126931
126952
  // can cause it to happen: see 'completionsImport_mergedReExport.ts'
126932
126953
  if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
126933
- cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, scriptTarget, checker);
126954
+ cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
126934
126955
  }
126935
126956
  checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
126936
126957
  if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
126937
- cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, scriptTarget, checker);
126958
+ cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
126938
126959
  }
126939
126960
  });
126940
126961
  });
@@ -129008,6 +129029,8 @@ var ts;
129008
129029
  CompletionSource["ThisProperty"] = "ThisProperty/";
129009
129030
  /** Auto-import that comes attached to a class member snippet */
129010
129031
  CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
129032
+ /** A type-only import that needs to be promoted in order to be used at the completion location */
129033
+ CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
129011
129034
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
129012
129035
  var SymbolOriginInfoKind;
129013
129036
  (function (SymbolOriginInfoKind) {
@@ -129017,6 +129040,7 @@ var ts;
129017
129040
  SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
129018
129041
  SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
129019
129042
  SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
129043
+ SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
129020
129044
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
129021
129045
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
129022
129046
  })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
@@ -129044,6 +129068,9 @@ var ts;
129044
129068
  function originIsNullableMember(origin) {
129045
129069
  return !!(origin.kind & 16 /* Nullable */);
129046
129070
  }
129071
+ function originIsTypeOnlyAlias(origin) {
129072
+ return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
129073
+ }
129047
129074
  var KeywordCompletionFilters;
129048
129075
  (function (KeywordCompletionFilters) {
129049
129076
  KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
@@ -129448,6 +129475,9 @@ var ts;
129448
129475
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
129449
129476
  }
129450
129477
  }
129478
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
129479
+ hasAction = true;
129480
+ }
129451
129481
  if (preferences.includeCompletionsWithClassMemberSnippets &&
129452
129482
  preferences.includeCompletionsWithInsertText &&
129453
129483
  completionKind === 3 /* MemberLike */ &&
@@ -129792,6 +129822,9 @@ var ts;
129792
129822
  if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
129793
129823
  return CompletionSource.ThisProperty;
129794
129824
  }
129825
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
129826
+ return CompletionSource.TypeOnlyAlias;
129827
+ }
129795
129828
  }
129796
129829
  function getCompletionEntriesFromSymbols(symbols, entries, replacementToken, contextToken, location, sourceFile, host, program, target, log, kind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, jsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag) {
129797
129830
  var _a;
@@ -129819,7 +129852,7 @@ var ts;
129819
129852
  continue;
129820
129853
  }
129821
129854
  /** True for locals; false for globals, module exports from other files, `this.` completions. */
129822
- var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
129855
+ var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
129823
129856
  uniques.set(name, shouldShadowLaterSymbols);
129824
129857
  ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
129825
129858
  }
@@ -129832,6 +129865,7 @@ var ts;
129832
129865
  add: function (name) { return uniques.set(name, true); },
129833
129866
  };
129834
129867
  function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
129868
+ var allFlags = symbol.flags;
129835
129869
  if (!ts.isSourceFile(location)) {
129836
129870
  // export = /**/ here we want to get all meanings, so any symbol is ok
129837
129871
  if (ts.isExportAssignment(location.parent)) {
@@ -129857,11 +129891,10 @@ var ts;
129857
129891
  || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
129858
129892
  return false;
129859
129893
  }
129860
- // Continue with origin symbol
129861
- symbol = symbolOrigin;
129894
+ allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
129862
129895
  // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
129863
129896
  if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
129864
- return !!(symbol.flags & 1920 /* Namespace */);
129897
+ return !!(allFlags & 1920 /* Namespace */);
129865
129898
  }
129866
129899
  if (isTypeOnlyLocation) {
129867
129900
  // It's a type, but you can reach it by namespace.type as well
@@ -129869,7 +129902,7 @@ var ts;
129869
129902
  }
129870
129903
  }
129871
129904
  // expressions are value space (which includes the value namespaces)
129872
- return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */);
129905
+ return !!(allFlags & 111551 /* Value */);
129873
129906
  }
129874
129907
  }
129875
129908
  Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
@@ -130003,8 +130036,7 @@ var ts;
130003
130036
  Completions.createCompletionDetails = createCompletionDetails;
130004
130037
  function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
130005
130038
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
130006
- var _a = getRelevantTokens(position, sourceFile), contextToken_3 = _a.contextToken, previousToken_2 = _a.previousToken;
130007
- if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
130039
+ if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
130008
130040
  // Import statement completion: 'import c|'
130009
130041
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
130010
130042
  }
@@ -130022,13 +130054,19 @@ var ts;
130022
130054
  };
130023
130055
  }
130024
130056
  }
130057
+ if (originIsTypeOnlyAlias(origin)) {
130058
+ var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
130059
+ ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
130060
+ return { codeActions: [codeAction_1], sourceDisplay: undefined };
130061
+ }
130025
130062
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
130026
130063
  return { codeActions: undefined, sourceDisplay: undefined };
130027
130064
  }
130028
130065
  var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
130029
130066
  var moduleSymbol = origin.moduleSymbol;
130030
130067
  var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
130031
- var _b = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions)), host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _b.moduleSpecifier, codeAction = _b.codeAction;
130068
+ var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
130069
+ var _a = ts.codefix.getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, ts.getNameForExportedSymbol(symbol, ts.getEmitScriptTarget(compilerOptions), isJsxOpeningTagName), isJsxOpeningTagName, host, program, formatContext, previousToken && ts.isIdentifier(previousToken) ? previousToken.getStart(sourceFile) : position, preferences), moduleSpecifier = _a.moduleSpecifier, codeAction = _a.codeAction;
130032
130070
  ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
130033
130071
  return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
130034
130072
  }
@@ -130698,21 +130736,29 @@ var ts;
130698
130736
  var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
130699
130737
  isInSnippetScope = isSnippetScope(scopeNode);
130700
130738
  var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
130739
+ var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
130701
130740
  symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
130702
130741
  ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
130703
- for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
130704
- var symbol = symbols_1[_i];
130742
+ for (var i = 0; i < symbols.length; i++) {
130743
+ var symbol = symbols[i];
130705
130744
  if (!typeChecker.isArgumentsSymbol(symbol) &&
130706
130745
  !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
130707
130746
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
130708
130747
  }
130748
+ if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
130749
+ var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
130750
+ if (typeOnlyAliasDeclaration) {
130751
+ var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
130752
+ symbolToOriginInfoMap[i] = origin;
130753
+ }
130754
+ }
130709
130755
  }
130710
130756
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
130711
130757
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
130712
130758
  var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
130713
130759
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
130714
- for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
130715
- var symbol = _b[_a];
130760
+ for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
130761
+ var symbol = _a[_i];
130716
130762
  symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
130717
130763
  symbols.push(symbol);
130718
130764
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
@@ -130815,7 +130861,8 @@ var ts;
130815
130861
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
130816
130862
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
130817
130863
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
130818
- exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule, exportMapKey) {
130864
+ exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
130865
+ var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
130819
130866
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
130820
130867
  return;
130821
130868
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
@@ -130825,6 +130872,10 @@ var ts;
130825
130872
  return;
130826
130873
  if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
130827
130874
  return;
130875
+ // Do not try to auto-import something with a lowercase first letter for a JSX tag
130876
+ var firstChar = symbolName.charCodeAt(0);
130877
+ if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
130878
+ return;
130828
130879
  var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
130829
130880
  if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
130830
130881
  var defaultExportInfo = ts.find(info, isImportableExportInfo);
@@ -130901,16 +130952,19 @@ var ts;
130901
130952
  return true;
130902
130953
  }
130903
130954
  if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) {
130955
+ // <Component<string> /**/ />
130956
+ // <Component<string> /**/ ><Component>
130957
+ // - contextToken: GreaterThanToken (before cursor)
130958
+ // - location: JsxSelfClosingElement or JsxOpeningElement
130959
+ // - contextToken.parent === location
130960
+ if (location === contextToken.parent && (location.kind === 279 /* JsxOpeningElement */ || location.kind === 278 /* JsxSelfClosingElement */)) {
130961
+ return false;
130962
+ }
130904
130963
  if (contextToken.parent.kind === 279 /* JsxOpeningElement */) {
130905
- // Two possibilities:
130906
- // 1. <div>/**/
130907
- // - contextToken: GreaterThanToken (before cursor)
130908
- // - location: JSXElement
130909
- // - different parents (JSXOpeningElement, JSXElement)
130910
- // 2. <Component<string> /**/>
130911
- // - contextToken: GreaterThanToken (before cursor)
130912
- // - location: GreaterThanToken (after cursor)
130913
- // - same parent (JSXOpeningElement)
130964
+ // <div>/**/
130965
+ // - contextToken: GreaterThanToken (before cursor)
130966
+ // - location: JSXElement
130967
+ // - different parents (JSXOpeningElement, JSXElement)
130914
130968
  return location.parent.kind !== 279 /* JsxOpeningElement */;
130915
130969
  }
130916
130970
  if (contextToken.parent.kind === 280 /* JsxClosingElement */ || contextToken.parent.kind === 278 /* JsxSelfClosingElement */) {
@@ -132111,10 +132165,14 @@ var ts;
132111
132165
  /** True if symbol is a type or a module containing at least one type. */
132112
132166
  function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
132113
132167
  if (seenModules === void 0) { seenModules = new ts.Map(); }
132114
- var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker);
132115
- return !!(sym.flags & 788968 /* Type */) || checker.isUnknownSymbol(sym) ||
132116
- !!(sym.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(sym)) &&
132117
- checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132168
+ // Since an alias can be merged with a local declaration, we need to test both the alias and its target.
132169
+ // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
132170
+ return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
132171
+ function nonAliasCanBeReferencedAtTypeLocation(symbol) {
132172
+ return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
132173
+ !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
132174
+ checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132175
+ }
132118
132176
  }
132119
132177
  function isDeprecated(symbol, checker) {
132120
132178
  var declarations = ts.skipAlias(symbol, checker).declarations;
@@ -134368,8 +134426,8 @@ var ts;
134368
134426
  var sourceId = ts.getNodeId(sourceFile);
134369
134427
  var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
134370
134428
  var anyNewSymbols = false;
134371
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
134372
- var sym = symbols_2[_i];
134429
+ for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
134430
+ var sym = symbols_1[_i];
134373
134431
  anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
134374
134432
  }
134375
134433
  return anyNewSymbols;
@@ -145240,6 +145298,7 @@ var ts;
145240
145298
  ChangeTracker.prototype.delete = function (sourceFile, node) {
145241
145299
  this.deletedNodes.push({ sourceFile: sourceFile, node: node });
145242
145300
  };
145301
+ /** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
145243
145302
  ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
145244
145303
  if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
145245
145304
  this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
@@ -145643,6 +145702,15 @@ var ts;
145643
145702
  ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
145644
145703
  this.insertText(sourceFile, node.getStart(sourceFile), "export ");
145645
145704
  };
145705
+ ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
145706
+ var prevSpecifier = namedImports.elements[index - 1];
145707
+ if (prevSpecifier) {
145708
+ this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
145709
+ }
145710
+ else {
145711
+ this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
145712
+ }
145713
+ };
145646
145714
  /**
145647
145715
  * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
145648
145716
  * i.e. arguments in arguments lists, parameters in parameter lists etc.
@@ -149145,7 +149213,8 @@ var ts;
149145
149213
  ts.Diagnostics.Cannot_find_namespace_0.code,
149146
149214
  ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
149147
149215
  ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
149148
- ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
149216
+ ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
149217
+ ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
149149
149218
  ];
149150
149219
  codefix.registerCodeFix({
149151
149220
  errorCodes: errorCodes,
@@ -149191,7 +149260,7 @@ var ts;
149191
149260
  var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
149192
149261
  var checker = program.getTypeChecker();
149193
149262
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
149194
- var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, preferences, useAutoImportProvider);
149263
+ var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
149195
149264
  var useRequire = shouldUseRequire(sourceFile, program);
149196
149265
  var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149197
149266
  if (fix) {
@@ -149250,6 +149319,9 @@ var ts;
149250
149319
  }
149251
149320
  break;
149252
149321
  }
149322
+ case 4 /* PromoteTypeOnly */:
149323
+ // Excluding from fix-all
149324
+ break;
149253
149325
  default:
149254
149326
  ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
149255
149327
  }
@@ -149341,6 +149413,7 @@ var ts;
149341
149413
  ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
149342
149414
  ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
149343
149415
  ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
149416
+ ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
149344
149417
  })(ImportFixKind || (ImportFixKind = {}));
149345
149418
  // These should not be combined as bitflags, but are given powers of 2 values to
149346
149419
  // easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
@@ -149352,11 +149425,11 @@ var ts;
149352
149425
  AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required";
149353
149426
  AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed";
149354
149427
  })(AddAsTypeOnly || (AddAsTypeOnly = {}));
149355
- function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
149428
+ function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, isJsxTagName, host, program, formatContext, position, preferences) {
149356
149429
  var compilerOptions = program.getCompilerOptions();
149357
149430
  var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
149358
149431
  ? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
149359
- : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
149432
+ : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
149360
149433
  var useRequire = shouldUseRequire(sourceFile, program);
149361
149434
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
149362
149435
  var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
@@ -149366,6 +149439,13 @@ var ts;
149366
149439
  };
149367
149440
  }
149368
149441
  codefix.getImportCompletionAction = getImportCompletionAction;
149442
+ function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
149443
+ var compilerOptions = program.getCompilerOptions();
149444
+ var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
149445
+ var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
149446
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
149447
+ }
149448
+ codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
149369
149449
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149370
149450
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149371
149451
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -149395,7 +149475,7 @@ var ts;
149395
149475
  }
149396
149476
  }
149397
149477
  }
149398
- function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) {
149478
+ function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences, useAutoImportProvider) {
149399
149479
  var result = [];
149400
149480
  var compilerOptions = program.getCompilerOptions();
149401
149481
  var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
@@ -149408,7 +149488,7 @@ var ts;
149408
149488
  return;
149409
149489
  }
149410
149490
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
149411
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
149491
+ if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
149412
149492
  result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson: isFromPackageJson });
149413
149493
  }
149414
149494
  for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
@@ -149646,9 +149726,21 @@ var ts;
149646
149726
  }
149647
149727
  function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
149648
149728
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
149649
- var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
149650
- ? getFixesInfoForUMDImport(context, symbolToken)
149651
- : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
149729
+ var info;
149730
+ if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
149731
+ info = getFixesInfoForUMDImport(context, symbolToken);
149732
+ }
149733
+ else if (!ts.isIdentifier(symbolToken)) {
149734
+ return undefined;
149735
+ }
149736
+ else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
149737
+ var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
149738
+ var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
149739
+ return fix && { fixes: [fix], symbolName: symbolName_1 };
149740
+ }
149741
+ else {
149742
+ info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
149743
+ }
149652
149744
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
149653
149745
  return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
149654
149746
  }
@@ -149765,13 +149857,23 @@ var ts;
149765
149857
  ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
149766
149858
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
149767
149859
  var useRequire = shouldUseRequire(sourceFile, program);
149768
- var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
149860
+ var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
149769
149861
  var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
149770
149862
  var _ = _a[0], exportInfos = _a[1];
149771
149863
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
149772
149864
  }));
149773
149865
  return { fixes: fixes, symbolName: symbolName };
149774
149866
  }
149867
+ function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
149868
+ var checker = program.getTypeChecker();
149869
+ var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
149870
+ if (!symbol)
149871
+ return undefined;
149872
+ var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
149873
+ if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
149874
+ return undefined;
149875
+ return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
149876
+ }
149775
149877
  function jsxModeNeedsExplicitImport(jsx) {
149776
149878
  return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
149777
149879
  }
@@ -149779,14 +149881,20 @@ var ts;
149779
149881
  var parent = symbolToken.parent;
149780
149882
  if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
149781
149883
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
149782
- if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
149884
+ if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
149783
149885
  return jsxNamespace;
149784
149886
  }
149785
149887
  }
149786
149888
  return symbolToken.text;
149787
149889
  }
149890
+ function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
149891
+ if (ts.isIntrinsicJsxName(symbolToken.text))
149892
+ return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
149893
+ var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
149894
+ return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
149895
+ }
149788
149896
  // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
149789
- function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
149897
+ function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
149790
149898
  var _a;
149791
149899
  // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
149792
149900
  // Maps symbol id to info for modules providing that symbol (original export + re-exports).
@@ -149809,7 +149917,7 @@ var ts;
149809
149917
  cancellationToken.throwIfCancellationRequested();
149810
149918
  var compilerOptions = program.getCompilerOptions();
149811
149919
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
149812
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
149920
+ if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
149813
149921
  addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
149814
149922
  }
149815
149923
  // check exports with the same name
@@ -149883,10 +149991,80 @@ var ts;
149883
149991
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
149884
149992
  return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
149885
149993
  }
149994
+ case 4 /* PromoteTypeOnly */: {
149995
+ var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
149996
+ var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
149997
+ return promotedDeclaration.kind === 269 /* ImportSpecifier */
149998
+ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
149999
+ : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
150000
+ }
149886
150001
  default:
149887
150002
  return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
149888
150003
  }
149889
150004
  }
150005
+ function getModuleSpecifierText(promotedDeclaration) {
150006
+ var _a, _b;
150007
+ return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
150008
+ ? ((_b = ts.tryCast((_a = ts.tryCast(promotedDeclaration.moduleReference, ts.isExternalModuleReference)) === null || _a === void 0 ? void 0 : _a.expression, ts.isStringLiteralLike)) === null || _b === void 0 ? void 0 : _b.text) || promotedDeclaration.moduleReference.getText()
150009
+ : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
150010
+ }
150011
+ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
150012
+ // See comment in `doAddExistingFix` on constant with the same name.
150013
+ var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
150014
+ switch (aliasDeclaration.kind) {
150015
+ case 269 /* ImportSpecifier */:
150016
+ if (aliasDeclaration.isTypeOnly) {
150017
+ if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
150018
+ changes.delete(sourceFile, aliasDeclaration);
150019
+ var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
150020
+ var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
150021
+ changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
150022
+ }
150023
+ else {
150024
+ changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
150025
+ }
150026
+ return aliasDeclaration;
150027
+ }
150028
+ else {
150029
+ ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
150030
+ promoteImportClause(aliasDeclaration.parent.parent);
150031
+ return aliasDeclaration.parent.parent;
150032
+ }
150033
+ case 266 /* ImportClause */:
150034
+ promoteImportClause(aliasDeclaration);
150035
+ return aliasDeclaration;
150036
+ case 267 /* NamespaceImport */:
150037
+ promoteImportClause(aliasDeclaration.parent);
150038
+ return aliasDeclaration.parent;
150039
+ case 264 /* ImportEqualsDeclaration */:
150040
+ changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
150041
+ return aliasDeclaration;
150042
+ default:
150043
+ ts.Debug.failBadSyntaxKind(aliasDeclaration);
150044
+ }
150045
+ function promoteImportClause(importClause) {
150046
+ changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
150047
+ if (convertExistingToTypeOnly) {
150048
+ var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
150049
+ if (namedImports && namedImports.elements.length > 1) {
150050
+ if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
150051
+ aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
150052
+ namedImports.elements.indexOf(aliasDeclaration) !== 0) {
150053
+ // The import specifier being promoted will be the only non-type-only,
150054
+ // import in the NamedImports, so it should be moved to the front.
150055
+ changes.delete(sourceFile, aliasDeclaration);
150056
+ changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
150057
+ }
150058
+ for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
150059
+ var element = _a[_i];
150060
+ if (element !== aliasDeclaration && !element.isTypeOnly) {
150061
+ changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
150062
+ }
150063
+ }
150064
+ }
150065
+ }
150066
+ }
150067
+ }
149890
150068
  function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
149891
150069
  var _a;
149892
150070
  if (clause.kind === 200 /* ObjectBindingPattern */) {
@@ -149924,13 +150102,7 @@ var ts;
149924
150102
  var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
149925
150103
  ? 0
149926
150104
  : ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
149927
- var prevSpecifier = clause.namedBindings.elements[insertionIndex - 1];
149928
- if (prevSpecifier) {
149929
- changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
149930
- }
149931
- else {
149932
- changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
149933
- }
150105
+ changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
149934
150106
  }
149935
150107
  }
149936
150108
  else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
@@ -150045,17 +150217,20 @@ var ts;
150045
150217
  var declarations = _a.declarations;
150046
150218
  return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); });
150047
150219
  }
150048
- function moduleSymbolToValidIdentifier(moduleSymbol, target) {
150049
- return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target);
150220
+ function moduleSymbolToValidIdentifier(moduleSymbol, target, forceCapitalize) {
150221
+ return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target, forceCapitalize);
150050
150222
  }
150051
150223
  codefix.moduleSymbolToValidIdentifier = moduleSymbolToValidIdentifier;
150052
- function moduleSpecifierToValidIdentifier(moduleSpecifier, target) {
150224
+ function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitalize) {
150053
150225
  var baseName = ts.getBaseFileName(ts.removeSuffix(moduleSpecifier, "/index"));
150054
150226
  var res = "";
150055
150227
  var lastCharWasValid = true;
150056
150228
  var firstCharCode = baseName.charCodeAt(0);
150057
150229
  if (ts.isIdentifierStart(firstCharCode, target)) {
150058
150230
  res += String.fromCharCode(firstCharCode);
150231
+ if (forceCapitalize) {
150232
+ res = res.toUpperCase();
150233
+ }
150059
150234
  }
150060
150235
  else {
150061
150236
  lastCharWasValid = false;