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.
@@ -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.20220126";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220127";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -9667,6 +9667,8 @@ var ts;
9667
9667
  Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
9668
9668
  Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
9669
9669
  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}'"),
9670
+ 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}\""),
9671
+ 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}\""),
9670
9672
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9671
9673
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9672
9674
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -15096,6 +15098,15 @@ var ts;
15096
15098
  };
15097
15099
  }
15098
15100
  ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain;
15101
+ function createDiagnosticMessageChainFromDiagnostic(diagnostic) {
15102
+ return typeof diagnostic.messageText === "string" ? {
15103
+ code: diagnostic.code,
15104
+ category: diagnostic.category,
15105
+ messageText: diagnostic.messageText,
15106
+ next: diagnostic.next,
15107
+ } : diagnostic.messageText;
15108
+ }
15109
+ ts.createDiagnosticMessageChainFromDiagnostic = createDiagnosticMessageChainFromDiagnostic;
15099
15110
  function createDiagnosticForRange(sourceFile, range, message) {
15100
15111
  return {
15101
15112
  file: sourceFile,
@@ -52729,7 +52740,8 @@ var ts;
52729
52740
  includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
52730
52741
  }
52731
52742
  if (ts.isIdentifier(node)) {
52732
- var name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.factory.cloneNode(node);
52743
+ var type = getDeclaredTypeOfSymbol(sym);
52744
+ var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
52733
52745
  name.symbol = sym; // for quickinfo, which uses identifier symbol information
52734
52746
  return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
52735
52747
  }
@@ -74621,7 +74633,7 @@ var ts;
74621
74633
  }
74622
74634
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
74623
74635
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
74624
- 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);
74636
+ var chain = ts.chainDiagnosticMessages(ts.map(diags_3, ts.createDiagnosticMessageChainFromDiagnostic), ts.Diagnostics.No_overload_matches_this_call);
74625
74637
  // 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
74626
74638
  // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic
74627
74639
  var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; }), true);
@@ -83000,16 +83012,15 @@ var ts;
83000
83012
  return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
83001
83013
  case 206 /* ElementAccessExpression */:
83002
83014
  case 205 /* PropertyAccessExpression */:
83003
- var ex = expr;
83004
- if (isConstantMemberAccess(ex)) {
83005
- var type = getTypeOfExpression(ex.expression);
83015
+ if (isConstantMemberAccess(expr)) {
83016
+ var type = getTypeOfExpression(expr.expression);
83006
83017
  if (type.symbol && type.symbol.flags & 384 /* Enum */) {
83007
83018
  var name = void 0;
83008
- if (ex.kind === 205 /* PropertyAccessExpression */) {
83009
- name = ex.name.escapedText;
83019
+ if (expr.kind === 205 /* PropertyAccessExpression */) {
83020
+ name = expr.name.escapedText;
83010
83021
  }
83011
83022
  else {
83012
- name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
83023
+ name = ts.escapeLeadingUnderscores(ts.cast(expr.argumentExpression, ts.isLiteralExpression).text);
83013
83024
  }
83014
83025
  return evaluateEnumMember(expr, type.symbol, name);
83015
83026
  }
@@ -83037,6 +83048,10 @@ var ts;
83037
83048
  }
83038
83049
  }
83039
83050
  function isConstantMemberAccess(node) {
83051
+ var type = getTypeOfExpression(node);
83052
+ if (type === errorType) {
83053
+ return false;
83054
+ }
83040
83055
  return node.kind === 79 /* Identifier */ ||
83041
83056
  node.kind === 205 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) ||
83042
83057
  node.kind === 206 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) &&
@@ -127167,11 +127182,11 @@ var ts;
127167
127182
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
127168
127183
  }
127169
127184
  ts.firstOrOnly = firstOrOnly;
127170
- function getNameForExportedSymbol(symbol, scriptTarget) {
127185
+ function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
127171
127186
  if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
127172
127187
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
127173
127188
  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; })
127174
- || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
127189
+ || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
127175
127190
  }
127176
127191
  return symbol.name;
127177
127192
  }
@@ -127299,7 +127314,7 @@ var ts;
127299
127314
  symbols.clear();
127300
127315
  usableByFileName = undefined;
127301
127316
  },
127302
- add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, scriptTarget, checker) {
127317
+ add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, checker) {
127303
127318
  if (importingFile !== usableByFileName) {
127304
127319
  cache.clear();
127305
127320
  usableByFileName = importingFile;
@@ -127315,7 +127330,7 @@ var ts;
127315
127330
  // get a better name.
127316
127331
  var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
127317
127332
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
127318
- : ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
127333
+ : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
127319
127334
  var moduleName = ts.stripQuotes(moduleSymbol.name);
127320
127335
  var id = exportInfoId++;
127321
127336
  var target = ts.skipAlias(symbol, checker);
@@ -127348,7 +127363,14 @@ var ts;
127348
127363
  return;
127349
127364
  exportInfo.forEach(function (info, key) {
127350
127365
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
127351
- action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName, key);
127366
+ var rehydrated = info.map(rehydrateCachedInfo);
127367
+ action(rehydrated, function (preferCapitalized) {
127368
+ var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
127369
+ var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
127370
+ return preferCapitalized
127371
+ ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
127372
+ : symbolName;
127373
+ }, !!ambientModuleName, key);
127352
127374
  });
127353
127375
  },
127354
127376
  releaseSymbols: function () {
@@ -127530,7 +127552,6 @@ var ts;
127530
127552
  }
127531
127553
  (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
127532
127554
  var compilerOptions = program.getCompilerOptions();
127533
- var scriptTarget = ts.getEmitScriptTarget(compilerOptions);
127534
127555
  var moduleCount = 0;
127535
127556
  forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
127536
127557
  if (++moduleCount % 100 === 0)
@@ -127541,11 +127562,11 @@ var ts;
127541
127562
  // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
127542
127563
  // can cause it to happen: see 'completionsImport_mergedReExport.ts'
127543
127564
  if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
127544
- cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, scriptTarget, checker);
127565
+ cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
127545
127566
  }
127546
127567
  checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
127547
127568
  if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
127548
- cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, scriptTarget, checker);
127569
+ cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
127549
127570
  }
127550
127571
  });
127551
127572
  });
@@ -129619,6 +129640,8 @@ var ts;
129619
129640
  CompletionSource["ThisProperty"] = "ThisProperty/";
129620
129641
  /** Auto-import that comes attached to a class member snippet */
129621
129642
  CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
129643
+ /** A type-only import that needs to be promoted in order to be used at the completion location */
129644
+ CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
129622
129645
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
129623
129646
  var SymbolOriginInfoKind;
129624
129647
  (function (SymbolOriginInfoKind) {
@@ -129628,6 +129651,7 @@ var ts;
129628
129651
  SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
129629
129652
  SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
129630
129653
  SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
129654
+ SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
129631
129655
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
129632
129656
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
129633
129657
  })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
@@ -129655,6 +129679,9 @@ var ts;
129655
129679
  function originIsNullableMember(origin) {
129656
129680
  return !!(origin.kind & 16 /* Nullable */);
129657
129681
  }
129682
+ function originIsTypeOnlyAlias(origin) {
129683
+ return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
129684
+ }
129658
129685
  var KeywordCompletionFilters;
129659
129686
  (function (KeywordCompletionFilters) {
129660
129687
  KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
@@ -130059,6 +130086,9 @@ var ts;
130059
130086
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
130060
130087
  }
130061
130088
  }
130089
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130090
+ hasAction = true;
130091
+ }
130062
130092
  if (preferences.includeCompletionsWithClassMemberSnippets &&
130063
130093
  preferences.includeCompletionsWithInsertText &&
130064
130094
  completionKind === 3 /* MemberLike */ &&
@@ -130403,6 +130433,9 @@ var ts;
130403
130433
  if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
130404
130434
  return CompletionSource.ThisProperty;
130405
130435
  }
130436
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
130437
+ return CompletionSource.TypeOnlyAlias;
130438
+ }
130406
130439
  }
130407
130440
  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) {
130408
130441
  var _a;
@@ -130430,7 +130463,7 @@ var ts;
130430
130463
  continue;
130431
130464
  }
130432
130465
  /** True for locals; false for globals, module exports from other files, `this.` completions. */
130433
- var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130466
+ var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
130434
130467
  uniques.set(name, shouldShadowLaterSymbols);
130435
130468
  ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
130436
130469
  }
@@ -130443,6 +130476,7 @@ var ts;
130443
130476
  add: function (name) { return uniques.set(name, true); },
130444
130477
  };
130445
130478
  function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
130479
+ var allFlags = symbol.flags;
130446
130480
  if (!ts.isSourceFile(location)) {
130447
130481
  // export = /**/ here we want to get all meanings, so any symbol is ok
130448
130482
  if (ts.isExportAssignment(location.parent)) {
@@ -130468,11 +130502,10 @@ var ts;
130468
130502
  || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
130469
130503
  return false;
130470
130504
  }
130471
- // Continue with origin symbol
130472
- symbol = symbolOrigin;
130505
+ allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
130473
130506
  // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
130474
130507
  if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
130475
- return !!(symbol.flags & 1920 /* Namespace */);
130508
+ return !!(allFlags & 1920 /* Namespace */);
130476
130509
  }
130477
130510
  if (isTypeOnlyLocation) {
130478
130511
  // It's a type, but you can reach it by namespace.type as well
@@ -130480,7 +130513,7 @@ var ts;
130480
130513
  }
130481
130514
  }
130482
130515
  // expressions are value space (which includes the value namespaces)
130483
- return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */);
130516
+ return !!(allFlags & 111551 /* Value */);
130484
130517
  }
130485
130518
  }
130486
130519
  Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
@@ -130614,8 +130647,7 @@ var ts;
130614
130647
  Completions.createCompletionDetails = createCompletionDetails;
130615
130648
  function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
130616
130649
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
130617
- var _a = getRelevantTokens(position, sourceFile), contextToken_3 = _a.contextToken, previousToken_2 = _a.previousToken;
130618
- if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
130650
+ if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
130619
130651
  // Import statement completion: 'import c|'
130620
130652
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
130621
130653
  }
@@ -130633,13 +130665,19 @@ var ts;
130633
130665
  };
130634
130666
  }
130635
130667
  }
130668
+ if (originIsTypeOnlyAlias(origin)) {
130669
+ var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
130670
+ ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
130671
+ return { codeActions: [codeAction_1], sourceDisplay: undefined };
130672
+ }
130636
130673
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
130637
130674
  return { codeActions: undefined, sourceDisplay: undefined };
130638
130675
  }
130639
130676
  var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
130640
130677
  var moduleSymbol = origin.moduleSymbol;
130641
130678
  var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
130642
- 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;
130679
+ var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
130680
+ 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;
130643
130681
  ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
130644
130682
  return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
130645
130683
  }
@@ -131309,21 +131347,29 @@ var ts;
131309
131347
  var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
131310
131348
  isInSnippetScope = isSnippetScope(scopeNode);
131311
131349
  var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
131350
+ var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
131312
131351
  symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
131313
131352
  ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
131314
- for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
131315
- var symbol = symbols_1[_i];
131353
+ for (var i = 0; i < symbols.length; i++) {
131354
+ var symbol = symbols[i];
131316
131355
  if (!typeChecker.isArgumentsSymbol(symbol) &&
131317
131356
  !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
131318
131357
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
131319
131358
  }
131359
+ if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
131360
+ var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
131361
+ if (typeOnlyAliasDeclaration) {
131362
+ var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
131363
+ symbolToOriginInfoMap[i] = origin;
131364
+ }
131365
+ }
131320
131366
  }
131321
131367
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
131322
131368
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
131323
131369
  var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
131324
131370
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
131325
- for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
131326
- var symbol = _b[_a];
131371
+ for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
131372
+ var symbol = _a[_i];
131327
131373
  symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
131328
131374
  symbols.push(symbol);
131329
131375
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
@@ -131426,7 +131472,8 @@ var ts;
131426
131472
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
131427
131473
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131428
131474
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
131429
- exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule, exportMapKey) {
131475
+ exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
131476
+ var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
131430
131477
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
131431
131478
  return;
131432
131479
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
@@ -131436,6 +131483,10 @@ var ts;
131436
131483
  return;
131437
131484
  if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131438
131485
  return;
131486
+ // Do not try to auto-import something with a lowercase first letter for a JSX tag
131487
+ var firstChar = symbolName.charCodeAt(0);
131488
+ if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
131489
+ return;
131439
131490
  var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
131440
131491
  if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
131441
131492
  var defaultExportInfo = ts.find(info, isImportableExportInfo);
@@ -131512,16 +131563,19 @@ var ts;
131512
131563
  return true;
131513
131564
  }
131514
131565
  if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) {
131566
+ // <Component<string> /**/ />
131567
+ // <Component<string> /**/ ><Component>
131568
+ // - contextToken: GreaterThanToken (before cursor)
131569
+ // - location: JsxSelfClosingElement or JsxOpeningElement
131570
+ // - contextToken.parent === location
131571
+ if (location === contextToken.parent && (location.kind === 279 /* JsxOpeningElement */ || location.kind === 278 /* JsxSelfClosingElement */)) {
131572
+ return false;
131573
+ }
131515
131574
  if (contextToken.parent.kind === 279 /* JsxOpeningElement */) {
131516
- // Two possibilities:
131517
- // 1. <div>/**/
131518
- // - contextToken: GreaterThanToken (before cursor)
131519
- // - location: JSXElement
131520
- // - different parents (JSXOpeningElement, JSXElement)
131521
- // 2. <Component<string> /**/>
131522
- // - contextToken: GreaterThanToken (before cursor)
131523
- // - location: GreaterThanToken (after cursor)
131524
- // - same parent (JSXOpeningElement)
131575
+ // <div>/**/
131576
+ // - contextToken: GreaterThanToken (before cursor)
131577
+ // - location: JSXElement
131578
+ // - different parents (JSXOpeningElement, JSXElement)
131525
131579
  return location.parent.kind !== 279 /* JsxOpeningElement */;
131526
131580
  }
131527
131581
  if (contextToken.parent.kind === 280 /* JsxClosingElement */ || contextToken.parent.kind === 278 /* JsxSelfClosingElement */) {
@@ -132722,10 +132776,14 @@ var ts;
132722
132776
  /** True if symbol is a type or a module containing at least one type. */
132723
132777
  function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
132724
132778
  if (seenModules === void 0) { seenModules = new ts.Map(); }
132725
- var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker);
132726
- return !!(sym.flags & 788968 /* Type */) || checker.isUnknownSymbol(sym) ||
132727
- !!(sym.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(sym)) &&
132728
- checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132779
+ // Since an alias can be merged with a local declaration, we need to test both the alias and its target.
132780
+ // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
132781
+ return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
132782
+ function nonAliasCanBeReferencedAtTypeLocation(symbol) {
132783
+ return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
132784
+ !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
132785
+ checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132786
+ }
132729
132787
  }
132730
132788
  function isDeprecated(symbol, checker) {
132731
132789
  var declarations = ts.skipAlias(symbol, checker).declarations;
@@ -134979,8 +135037,8 @@ var ts;
134979
135037
  var sourceId = ts.getNodeId(sourceFile);
134980
135038
  var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
134981
135039
  var anyNewSymbols = false;
134982
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
134983
- var sym = symbols_2[_i];
135040
+ for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
135041
+ var sym = symbols_1[_i];
134984
135042
  anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
134985
135043
  }
134986
135044
  return anyNewSymbols;
@@ -145851,6 +145909,7 @@ var ts;
145851
145909
  ChangeTracker.prototype.delete = function (sourceFile, node) {
145852
145910
  this.deletedNodes.push({ sourceFile: sourceFile, node: node });
145853
145911
  };
145912
+ /** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
145854
145913
  ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
145855
145914
  if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
145856
145915
  this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
@@ -146254,6 +146313,15 @@ var ts;
146254
146313
  ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
146255
146314
  this.insertText(sourceFile, node.getStart(sourceFile), "export ");
146256
146315
  };
146316
+ ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
146317
+ var prevSpecifier = namedImports.elements[index - 1];
146318
+ if (prevSpecifier) {
146319
+ this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
146320
+ }
146321
+ else {
146322
+ this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
146323
+ }
146324
+ };
146257
146325
  /**
146258
146326
  * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
146259
146327
  * i.e. arguments in arguments lists, parameters in parameter lists etc.
@@ -149756,7 +149824,8 @@ var ts;
149756
149824
  ts.Diagnostics.Cannot_find_namespace_0.code,
149757
149825
  ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
149758
149826
  ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
149759
- ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
149827
+ ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
149828
+ ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
149760
149829
  ];
149761
149830
  codefix.registerCodeFix({
149762
149831
  errorCodes: errorCodes,
@@ -149802,7 +149871,7 @@ var ts;
149802
149871
  var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
149803
149872
  var checker = program.getTypeChecker();
149804
149873
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
149805
- var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, preferences, useAutoImportProvider);
149874
+ var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
149806
149875
  var useRequire = shouldUseRequire(sourceFile, program);
149807
149876
  var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149808
149877
  if (fix) {
@@ -149861,6 +149930,9 @@ var ts;
149861
149930
  }
149862
149931
  break;
149863
149932
  }
149933
+ case 4 /* PromoteTypeOnly */:
149934
+ // Excluding from fix-all
149935
+ break;
149864
149936
  default:
149865
149937
  ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
149866
149938
  }
@@ -149952,6 +150024,7 @@ var ts;
149952
150024
  ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
149953
150025
  ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
149954
150026
  ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
150027
+ ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
149955
150028
  })(ImportFixKind || (ImportFixKind = {}));
149956
150029
  // These should not be combined as bitflags, but are given powers of 2 values to
149957
150030
  // easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
@@ -149963,11 +150036,11 @@ var ts;
149963
150036
  AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required";
149964
150037
  AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed";
149965
150038
  })(AddAsTypeOnly || (AddAsTypeOnly = {}));
149966
- function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
150039
+ function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, isJsxTagName, host, program, formatContext, position, preferences) {
149967
150040
  var compilerOptions = program.getCompilerOptions();
149968
150041
  var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
149969
150042
  ? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
149970
- : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
150043
+ : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
149971
150044
  var useRequire = shouldUseRequire(sourceFile, program);
149972
150045
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
149973
150046
  var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
@@ -149977,6 +150050,13 @@ var ts;
149977
150050
  };
149978
150051
  }
149979
150052
  codefix.getImportCompletionAction = getImportCompletionAction;
150053
+ function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
150054
+ var compilerOptions = program.getCompilerOptions();
150055
+ var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
150056
+ var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
150057
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, 1 /* Double */, compilerOptions));
150058
+ }
150059
+ codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
149980
150060
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149981
150061
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149982
150062
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -150006,7 +150086,7 @@ var ts;
150006
150086
  }
150007
150087
  }
150008
150088
  }
150009
- function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) {
150089
+ function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences, useAutoImportProvider) {
150010
150090
  var result = [];
150011
150091
  var compilerOptions = program.getCompilerOptions();
150012
150092
  var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
@@ -150019,7 +150099,7 @@ var ts;
150019
150099
  return;
150020
150100
  }
150021
150101
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
150022
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
150102
+ if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
150023
150103
  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 });
150024
150104
  }
150025
150105
  for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
@@ -150257,9 +150337,21 @@ var ts;
150257
150337
  }
150258
150338
  function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
150259
150339
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
150260
- var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
150261
- ? getFixesInfoForUMDImport(context, symbolToken)
150262
- : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
150340
+ var info;
150341
+ if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
150342
+ info = getFixesInfoForUMDImport(context, symbolToken);
150343
+ }
150344
+ else if (!ts.isIdentifier(symbolToken)) {
150345
+ return undefined;
150346
+ }
150347
+ else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
150348
+ var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
150349
+ var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
150350
+ return fix && { fixes: [fix], symbolName: symbolName_1 };
150351
+ }
150352
+ else {
150353
+ info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
150354
+ }
150263
150355
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
150264
150356
  return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
150265
150357
  }
@@ -150376,13 +150468,23 @@ var ts;
150376
150468
  ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
150377
150469
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
150378
150470
  var useRequire = shouldUseRequire(sourceFile, program);
150379
- var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
150471
+ var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
150380
150472
  var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
150381
150473
  var _ = _a[0], exportInfos = _a[1];
150382
150474
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
150383
150475
  }));
150384
150476
  return { fixes: fixes, symbolName: symbolName };
150385
150477
  }
150478
+ function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
150479
+ var checker = program.getTypeChecker();
150480
+ var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
150481
+ if (!symbol)
150482
+ return undefined;
150483
+ var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
150484
+ if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
150485
+ return undefined;
150486
+ return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
150487
+ }
150386
150488
  function jsxModeNeedsExplicitImport(jsx) {
150387
150489
  return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
150388
150490
  }
@@ -150390,14 +150492,20 @@ var ts;
150390
150492
  var parent = symbolToken.parent;
150391
150493
  if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
150392
150494
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
150393
- if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
150495
+ if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
150394
150496
  return jsxNamespace;
150395
150497
  }
150396
150498
  }
150397
150499
  return symbolToken.text;
150398
150500
  }
150501
+ function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
150502
+ if (ts.isIntrinsicJsxName(symbolToken.text))
150503
+ return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
150504
+ var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
150505
+ return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
150506
+ }
150399
150507
  // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
150400
- function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
150508
+ function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
150401
150509
  var _a;
150402
150510
  // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
150403
150511
  // Maps symbol id to info for modules providing that symbol (original export + re-exports).
@@ -150420,7 +150528,7 @@ var ts;
150420
150528
  cancellationToken.throwIfCancellationRequested();
150421
150529
  var compilerOptions = program.getCompilerOptions();
150422
150530
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
150423
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
150531
+ if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
150424
150532
  addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
150425
150533
  }
150426
150534
  // check exports with the same name
@@ -150494,10 +150602,80 @@ var ts;
150494
150602
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
150495
150603
  return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
150496
150604
  }
150605
+ case 4 /* PromoteTypeOnly */: {
150606
+ var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
150607
+ var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
150608
+ return promotedDeclaration.kind === 269 /* ImportSpecifier */
150609
+ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
150610
+ : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
150611
+ }
150497
150612
  default:
150498
150613
  return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
150499
150614
  }
150500
150615
  }
150616
+ function getModuleSpecifierText(promotedDeclaration) {
150617
+ var _a, _b;
150618
+ return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
150619
+ ? ((_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()
150620
+ : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
150621
+ }
150622
+ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
150623
+ // See comment in `doAddExistingFix` on constant with the same name.
150624
+ var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
150625
+ switch (aliasDeclaration.kind) {
150626
+ case 269 /* ImportSpecifier */:
150627
+ if (aliasDeclaration.isTypeOnly) {
150628
+ if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
150629
+ changes.delete(sourceFile, aliasDeclaration);
150630
+ var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
150631
+ var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
150632
+ changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
150633
+ }
150634
+ else {
150635
+ changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
150636
+ }
150637
+ return aliasDeclaration;
150638
+ }
150639
+ else {
150640
+ ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
150641
+ promoteImportClause(aliasDeclaration.parent.parent);
150642
+ return aliasDeclaration.parent.parent;
150643
+ }
150644
+ case 266 /* ImportClause */:
150645
+ promoteImportClause(aliasDeclaration);
150646
+ return aliasDeclaration;
150647
+ case 267 /* NamespaceImport */:
150648
+ promoteImportClause(aliasDeclaration.parent);
150649
+ return aliasDeclaration.parent;
150650
+ case 264 /* ImportEqualsDeclaration */:
150651
+ changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
150652
+ return aliasDeclaration;
150653
+ default:
150654
+ ts.Debug.failBadSyntaxKind(aliasDeclaration);
150655
+ }
150656
+ function promoteImportClause(importClause) {
150657
+ changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
150658
+ if (convertExistingToTypeOnly) {
150659
+ var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
150660
+ if (namedImports && namedImports.elements.length > 1) {
150661
+ if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
150662
+ aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
150663
+ namedImports.elements.indexOf(aliasDeclaration) !== 0) {
150664
+ // The import specifier being promoted will be the only non-type-only,
150665
+ // import in the NamedImports, so it should be moved to the front.
150666
+ changes.delete(sourceFile, aliasDeclaration);
150667
+ changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
150668
+ }
150669
+ for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
150670
+ var element = _a[_i];
150671
+ if (element !== aliasDeclaration && !element.isTypeOnly) {
150672
+ changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
150673
+ }
150674
+ }
150675
+ }
150676
+ }
150677
+ }
150678
+ }
150501
150679
  function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
150502
150680
  var _a;
150503
150681
  if (clause.kind === 200 /* ObjectBindingPattern */) {
@@ -150535,13 +150713,7 @@ var ts;
150535
150713
  var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
150536
150714
  ? 0
150537
150715
  : ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
150538
- var prevSpecifier = clause.namedBindings.elements[insertionIndex - 1];
150539
- if (prevSpecifier) {
150540
- changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
150541
- }
150542
- else {
150543
- changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
150544
- }
150716
+ changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
150545
150717
  }
150546
150718
  }
150547
150719
  else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
@@ -150656,17 +150828,20 @@ var ts;
150656
150828
  var declarations = _a.declarations;
150657
150829
  return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); });
150658
150830
  }
150659
- function moduleSymbolToValidIdentifier(moduleSymbol, target) {
150660
- return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target);
150831
+ function moduleSymbolToValidIdentifier(moduleSymbol, target, forceCapitalize) {
150832
+ return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target, forceCapitalize);
150661
150833
  }
150662
150834
  codefix.moduleSymbolToValidIdentifier = moduleSymbolToValidIdentifier;
150663
- function moduleSpecifierToValidIdentifier(moduleSpecifier, target) {
150835
+ function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitalize) {
150664
150836
  var baseName = ts.getBaseFileName(ts.removeSuffix(moduleSpecifier, "/index"));
150665
150837
  var res = "";
150666
150838
  var lastCharWasValid = true;
150667
150839
  var firstCharCode = baseName.charCodeAt(0);
150668
150840
  if (ts.isIdentifierStart(firstCharCode, target)) {
150669
150841
  res += String.fromCharCode(firstCharCode);
150842
+ if (forceCapitalize) {
150843
+ res = res.toUpperCase();
150844
+ }
150670
150845
  }
150671
150846
  else {
150672
150847
  lastCharWasValid = false;