typescript 4.6.0-dev.20220124 → 4.6.0-dev.20220128

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.20220124";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220128";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -111,13 +111,18 @@ var ts;
111
111
  /* @internal */
112
112
  var NativeCollections;
113
113
  (function (NativeCollections) {
114
+ var globals = typeof globalThis !== "undefined" ? globalThis :
115
+ typeof global !== "undefined" ? global :
116
+ typeof self !== "undefined" ? self :
117
+ undefined;
114
118
  /**
115
119
  * Returns the native Map implementation if it is available and compatible (i.e. supports iteration).
116
120
  */
117
121
  function tryGetNativeMap() {
118
122
  // Internet Explorer's Map doesn't support iteration, so don't use it.
123
+ var gMap = globals === null || globals === void 0 ? void 0 : globals.Map;
119
124
  // eslint-disable-next-line no-in-operator
120
- return typeof Map !== "undefined" && "entries" in Map.prototype && new Map([[0, 0]]).size === 1 ? Map : undefined;
125
+ return typeof gMap !== "undefined" && "entries" in gMap.prototype && new gMap([[0, 0]]).size === 1 ? gMap : undefined;
121
126
  }
122
127
  NativeCollections.tryGetNativeMap = tryGetNativeMap;
123
128
  /**
@@ -125,8 +130,9 @@ var ts;
125
130
  */
126
131
  function tryGetNativeSet() {
127
132
  // Internet Explorer's Set doesn't support iteration, so don't use it.
133
+ var gSet = globals === null || globals === void 0 ? void 0 : globals.Set;
128
134
  // eslint-disable-next-line no-in-operator
129
- return typeof Set !== "undefined" && "entries" in Set.prototype && new Set([0]).size === 1 ? Set : undefined;
135
+ return typeof gSet !== "undefined" && "entries" in gSet.prototype && new gSet([0]).size === 1 ? gSet : undefined;
130
136
  }
131
137
  NativeCollections.tryGetNativeSet = tryGetNativeSet;
132
138
  })(NativeCollections || (NativeCollections = {}));
@@ -9437,9 +9443,8 @@ var ts;
9437
9443
  Remove_variable_statement: diag(90010, ts.DiagnosticCategory.Message, "Remove_variable_statement_90010", "Remove variable statement"),
9438
9444
  Remove_template_tag: diag(90011, ts.DiagnosticCategory.Message, "Remove_template_tag_90011", "Remove template tag"),
9439
9445
  Remove_type_parameters: diag(90012, ts.DiagnosticCategory.Message, "Remove_type_parameters_90012", "Remove type parameters"),
9440
- Import_0_from_module_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_module_1_90013", "Import '{0}' from module \"{1}\""),
9446
+ Import_0_from_1: diag(90013, ts.DiagnosticCategory.Message, "Import_0_from_1_90013", "Import '{0}' from \"{1}\""),
9441
9447
  Change_0_to_1: diag(90014, ts.DiagnosticCategory.Message, "Change_0_to_1_90014", "Change '{0}' to '{1}'"),
9442
- Add_0_to_existing_import_declaration_from_1: diag(90015, ts.DiagnosticCategory.Message, "Add_0_to_existing_import_declaration_from_1_90015", "Add '{0}' to existing import declaration from \"{1}\""),
9443
9448
  Declare_property_0: diag(90016, ts.DiagnosticCategory.Message, "Declare_property_0_90016", "Declare property '{0}'"),
9444
9449
  Add_index_signature_for_property_0: diag(90017, ts.DiagnosticCategory.Message, "Add_index_signature_for_property_0_90017", "Add index signature for property '{0}'"),
9445
9450
  Disable_checking_for_this_file: diag(90018, ts.DiagnosticCategory.Message, "Disable_checking_for_this_file_90018", "Disable checking for this file"),
@@ -9456,8 +9461,6 @@ var ts;
9456
9461
  Add_async_modifier_to_containing_function: diag(90029, ts.DiagnosticCategory.Message, "Add_async_modifier_to_containing_function_90029", "Add async modifier to containing function"),
9457
9462
  Replace_infer_0_with_unknown: diag(90030, ts.DiagnosticCategory.Message, "Replace_infer_0_with_unknown_90030", "Replace 'infer {0}' with 'unknown'"),
9458
9463
  Replace_all_unused_infer_with_unknown: diag(90031, ts.DiagnosticCategory.Message, "Replace_all_unused_infer_with_unknown_90031", "Replace all unused 'infer' with 'unknown'"),
9459
- Import_default_0_from_module_1: diag(90032, ts.DiagnosticCategory.Message, "Import_default_0_from_module_1_90032", "Import default '{0}' from module \"{1}\""),
9460
- Add_default_import_0_to_existing_import_declaration_from_1: diag(90033, ts.DiagnosticCategory.Message, "Add_default_import_0_to_existing_import_declaration_from_1_90033", "Add default import '{0}' to existing import declaration from \"{1}\""),
9461
9464
  Add_parameter_name: diag(90034, ts.DiagnosticCategory.Message, "Add_parameter_name_90034", "Add parameter name"),
9462
9465
  Declare_private_property_0: diag(90035, ts.DiagnosticCategory.Message, "Declare_private_property_0_90035", "Declare private property '{0}'"),
9463
9466
  Replace_0_with_Promise_1: diag(90036, ts.DiagnosticCategory.Message, "Replace_0_with_Promise_1_90036", "Replace '{0}' with 'Promise<{1}>'"),
@@ -9467,6 +9470,10 @@ var ts;
9467
9470
  Remove_unused_declarations_for_Colon_0: diag(90041, ts.DiagnosticCategory.Message, "Remove_unused_declarations_for_Colon_0_90041", "Remove unused declarations for: '{0}'"),
9468
9471
  Declare_a_private_field_named_0: diag(90053, ts.DiagnosticCategory.Message, "Declare_a_private_field_named_0_90053", "Declare a private field named '{0}'."),
9469
9472
  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}'"),
9473
+ 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}\""),
9474
+ 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}\""),
9475
+ Add_import_from_0: diag(90057, ts.DiagnosticCategory.Message, "Add_import_from_0_90057", "Add import from \"{0}\""),
9476
+ Update_import_from_0: diag(90058, ts.DiagnosticCategory.Message, "Update_import_from_0_90058", "Update import from \"{0}\""),
9470
9477
  Convert_function_to_an_ES2015_class: diag(95001, ts.DiagnosticCategory.Message, "Convert_function_to_an_ES2015_class_95001", "Convert function to an ES2015 class"),
9471
9478
  Convert_0_to_1_in_0: diag(95003, ts.DiagnosticCategory.Message, "Convert_0_to_1_in_0_95003", "Convert '{0}' to '{1} in {0}'"),
9472
9479
  Extract_to_0_in_1: diag(95004, ts.DiagnosticCategory.Message, "Extract_to_0_in_1_95004", "Extract to {0} in {1}"),
@@ -14057,10 +14064,13 @@ var ts;
14057
14064
  function packageIdIsEqual(a, b) {
14058
14065
  return a === b || !!a && !!b && a.name === b.name && a.subModuleName === b.subModuleName && a.version === b.version;
14059
14066
  }
14060
- function packageIdToString(_a) {
14061
- var name = _a.name, subModuleName = _a.subModuleName, version = _a.version;
14062
- var fullName = subModuleName ? name + "/" + subModuleName : name;
14063
- return fullName + "@" + version;
14067
+ function packageIdToPackageName(_a) {
14068
+ var name = _a.name, subModuleName = _a.subModuleName;
14069
+ return subModuleName ? name + "/" + subModuleName : name;
14070
+ }
14071
+ ts.packageIdToPackageName = packageIdToPackageName;
14072
+ function packageIdToString(packageId) {
14073
+ return packageIdToPackageName(packageId) + "@" + packageId.version;
14064
14074
  }
14065
14075
  ts.packageIdToString = packageIdToString;
14066
14076
  function typeDirectiveIsEqualTo(oldResolution, newResolution) {
@@ -14893,6 +14903,15 @@ var ts;
14893
14903
  };
14894
14904
  }
14895
14905
  ts.createDiagnosticForFileFromMessageChain = createDiagnosticForFileFromMessageChain;
14906
+ function createDiagnosticMessageChainFromDiagnostic(diagnostic) {
14907
+ return typeof diagnostic.messageText === "string" ? {
14908
+ code: diagnostic.code,
14909
+ category: diagnostic.category,
14910
+ messageText: diagnostic.messageText,
14911
+ next: diagnostic.next,
14912
+ } : diagnostic.messageText;
14913
+ }
14914
+ ts.createDiagnosticMessageChainFromDiagnostic = createDiagnosticMessageChainFromDiagnostic;
14896
14915
  function createDiagnosticForRange(sourceFile, range, message) {
14897
14916
  return {
14898
14917
  file: sourceFile,
@@ -15061,7 +15080,8 @@ var ts;
15061
15080
  node.kind === 212 /* FunctionExpression */ ||
15062
15081
  node.kind === 213 /* ArrowFunction */ ||
15063
15082
  node.kind === 211 /* ParenthesizedExpression */ ||
15064
- node.kind === 253 /* VariableDeclaration */) ?
15083
+ node.kind === 253 /* VariableDeclaration */ ||
15084
+ node.kind === 274 /* ExportSpecifier */) ?
15065
15085
  ts.concatenate(ts.getTrailingCommentRanges(text, node.pos), ts.getLeadingCommentRanges(text, node.pos)) :
15066
15086
  ts.getLeadingCommentRanges(text, node.pos);
15067
15087
  // True if the comment starts with '/**' but not if it is '/**/'
@@ -20852,6 +20872,59 @@ var ts;
20852
20872
  return !!(type.flags & 262144 /* TypeParameter */ && type.isThisType);
20853
20873
  }
20854
20874
  ts.isThisTypeParameter = isThisTypeParameter;
20875
+ function getNodeModulePathParts(fullPath) {
20876
+ // If fullPath can't be valid module file within node_modules, returns undefined.
20877
+ // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
20878
+ // Returns indices: ^ ^ ^ ^
20879
+ var topLevelNodeModulesIndex = 0;
20880
+ var topLevelPackageNameIndex = 0;
20881
+ var packageRootIndex = 0;
20882
+ var fileNameIndex = 0;
20883
+ var States;
20884
+ (function (States) {
20885
+ States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
20886
+ States[States["NodeModules"] = 1] = "NodeModules";
20887
+ States[States["Scope"] = 2] = "Scope";
20888
+ States[States["PackageContent"] = 3] = "PackageContent";
20889
+ })(States || (States = {}));
20890
+ var partStart = 0;
20891
+ var partEnd = 0;
20892
+ var state = 0 /* BeforeNodeModules */;
20893
+ while (partEnd >= 0) {
20894
+ partStart = partEnd;
20895
+ partEnd = fullPath.indexOf("/", partStart + 1);
20896
+ switch (state) {
20897
+ case 0 /* BeforeNodeModules */:
20898
+ if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
20899
+ topLevelNodeModulesIndex = partStart;
20900
+ topLevelPackageNameIndex = partEnd;
20901
+ state = 1 /* NodeModules */;
20902
+ }
20903
+ break;
20904
+ case 1 /* NodeModules */:
20905
+ case 2 /* Scope */:
20906
+ if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
20907
+ state = 2 /* Scope */;
20908
+ }
20909
+ else {
20910
+ packageRootIndex = partEnd;
20911
+ state = 3 /* PackageContent */;
20912
+ }
20913
+ break;
20914
+ case 3 /* PackageContent */:
20915
+ if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
20916
+ state = 1 /* NodeModules */;
20917
+ }
20918
+ else {
20919
+ state = 3 /* PackageContent */;
20920
+ }
20921
+ break;
20922
+ }
20923
+ }
20924
+ fileNameIndex = partStart;
20925
+ return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
20926
+ }
20927
+ ts.getNodeModulePathParts = getNodeModulePathParts;
20855
20928
  })(ts || (ts = {}));
20856
20929
  /* @internal */
20857
20930
  var ts;
@@ -36212,7 +36285,8 @@ var ts;
36212
36285
  return finishNode(node, pos);
36213
36286
  }
36214
36287
  function parseExportSpecifier() {
36215
- return parseImportOrExportSpecifier(274 /* ExportSpecifier */);
36288
+ var hasJSDoc = hasPrecedingJSDocComment();
36289
+ return withJSDoc(parseImportOrExportSpecifier(274 /* ExportSpecifier */), hasJSDoc);
36216
36290
  }
36217
36291
  function parseImportSpecifier() {
36218
36292
  return parseImportOrExportSpecifier(269 /* ImportSpecifier */);
@@ -43417,14 +43491,12 @@ var ts;
43417
43491
  }
43418
43492
  var binder = createBinder();
43419
43493
  function bindSourceFile(file, options) {
43420
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
43421
43494
  ts.performance.mark("beforeBind");
43422
43495
  ts.perfLogger.logStartBindFile("" + file.fileName);
43423
43496
  binder(file, options);
43424
43497
  ts.perfLogger.logStopBindFile();
43425
43498
  ts.performance.mark("afterBind");
43426
43499
  ts.performance.measure("Bind", "beforeBind", "afterBind");
43427
- ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
43428
43500
  }
43429
43501
  ts.bindSourceFile = bindSourceFile;
43430
43502
  function createBinder() {
@@ -43484,7 +43556,9 @@ var ts;
43484
43556
  ts.Debug.attachFlowNodeDebugInfo(unreachableFlow);
43485
43557
  ts.Debug.attachFlowNodeDebugInfo(reportedUnreachableFlow);
43486
43558
  if (!file.locals) {
43559
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.push("bind" /* Bind */, "bindSourceFile", { path: file.path }, /*separateBeginAndEnd*/ true);
43487
43560
  bind(file);
43561
+ ts.tracing === null || ts.tracing === void 0 ? void 0 : ts.tracing.pop();
43488
43562
  file.symbolCount = symbolCount;
43489
43563
  file.classifiableNames = classifiableNames;
43490
43564
  delayedBindJSDocTypedefTag();
@@ -47751,6 +47825,9 @@ var ts;
47751
47825
  suggestionDiagnostics.add(diagnostic);
47752
47826
  return diagnostic;
47753
47827
  }
47828
+ function isDeprecatedSymbol(symbol) {
47829
+ return !!(getDeclarationNodeFlagsFromSymbol(symbol) & 134217728 /* Deprecated */);
47830
+ }
47754
47831
  function addDeprecatedSuggestion(location, declarations, deprecatedEntity) {
47755
47832
  var diagnostic = ts.createDiagnosticForNode(location, ts.Diagnostics._0_is_deprecated, deprecatedEntity);
47756
47833
  return addDeprecatedSuggestionWorker(declarations, diagnostic);
@@ -48742,24 +48819,19 @@ var ts;
48742
48819
  error(errorLocation, ts.Diagnostics.Parameter_0_cannot_reference_identifier_1_declared_after_it, ts.declarationNameToString(associatedDeclarationForContainingInitializerOrBindingName.name), ts.declarationNameToString(errorLocation));
48743
48820
  }
48744
48821
  }
48745
- if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */) {
48746
- checkSymbolUsageInExpressionContext(result, name, errorLocation);
48822
+ if (result && errorLocation && meaning & 111551 /* Value */ && result.flags & 2097152 /* Alias */ && !(result.flags & 111551 /* Value */) && !ts.isValidTypeOnlyAliasUseSite(errorLocation)) {
48823
+ var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(result);
48824
+ if (typeOnlyDeclaration) {
48825
+ var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
48826
+ ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
48827
+ : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
48828
+ var unescapedName = ts.unescapeLeadingUnderscores(name);
48829
+ addTypeOnlyDeclarationRelatedInfo(error(errorLocation, message, unescapedName), typeOnlyDeclaration, unescapedName);
48830
+ }
48747
48831
  }
48748
48832
  }
48749
48833
  return result;
48750
48834
  }
48751
- function checkSymbolUsageInExpressionContext(symbol, name, useSite) {
48752
- if (!ts.isValidTypeOnlyAliasUseSite(useSite)) {
48753
- var typeOnlyDeclaration = getTypeOnlyAliasDeclaration(symbol);
48754
- if (typeOnlyDeclaration) {
48755
- var message = typeOnlyDeclaration.kind === 274 /* ExportSpecifier */
48756
- ? ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_exported_using_export_type
48757
- : ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type;
48758
- var unescapedName = ts.unescapeLeadingUnderscores(name);
48759
- addTypeOnlyDeclarationRelatedInfo(error(useSite, message, unescapedName), typeOnlyDeclaration, unescapedName);
48760
- }
48761
- }
48762
- }
48763
48835
  function addTypeOnlyDeclarationRelatedInfo(diagnostic, typeOnlyDeclaration, unescapedName) {
48764
48836
  if (!typeOnlyDeclaration)
48765
48837
  return diagnostic;
@@ -52521,7 +52593,8 @@ var ts;
52521
52593
  includePrivateSymbol === null || includePrivateSymbol === void 0 ? void 0 : includePrivateSymbol(sym);
52522
52594
  }
52523
52595
  if (ts.isIdentifier(node)) {
52524
- var name = sym.flags & 262144 /* TypeParameter */ ? typeParameterToName(getDeclaredTypeOfSymbol(sym), context) : ts.factory.cloneNode(node);
52596
+ var type = getDeclaredTypeOfSymbol(sym);
52597
+ var name = sym.flags & 262144 /* TypeParameter */ && !isTypeSymbolAccessible(type.symbol, context.enclosingDeclaration) ? typeParameterToName(type, context) : ts.factory.cloneNode(node);
52525
52598
  name.symbol = sym; // for quickinfo, which uses identifier symbol information
52526
52599
  return { introducesError: introducesError, node: ts.setEmitFlags(ts.setOriginalNode(name, node), 16777216 /* NoAsciiEscaping */) };
52527
52600
  }
@@ -60537,7 +60610,7 @@ var ts;
60537
60610
  }
60538
60611
  var prop = getPropertyOfType(objectType, propName);
60539
60612
  if (prop) {
60540
- if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(accessNode, prop)) {
60613
+ if (accessFlags & 64 /* ReportDeprecated */ && accessNode && prop.declarations && isDeprecatedSymbol(prop) && isUncalledFunctionReference(accessNode, prop)) {
60541
60614
  var deprecatedNode = (_a = accessExpression === null || accessExpression === void 0 ? void 0 : accessExpression.argumentExpression) !== null && _a !== void 0 ? _a : (ts.isIndexedAccessTypeNode(accessNode) ? accessNode.indexType : accessNode);
60542
60615
  addDeprecatedSuggestion(deprecatedNode, prop.declarations, propName);
60543
60616
  }
@@ -69940,9 +70013,9 @@ var ts;
69940
70013
  markAliasReferenced(symbol, node);
69941
70014
  }
69942
70015
  var localOrExportSymbol = getExportSymbolOfValueSymbolIfExported(symbol);
69943
- var sourceSymbol = localOrExportSymbol.flags & 2097152 /* Alias */ ? resolveAlias(localOrExportSymbol) : localOrExportSymbol;
69944
- if (sourceSymbol.declarations && getDeclarationNodeFlagsFromSymbol(sourceSymbol) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, sourceSymbol)) {
69945
- addDeprecatedSuggestion(node, sourceSymbol.declarations, node.escapedText);
70016
+ var targetSymbol = checkDeprecatedAliasedSymbol(localOrExportSymbol, node);
70017
+ if (isDeprecatedSymbol(targetSymbol) && isUncalledFunctionReference(node, targetSymbol) && targetSymbol.declarations) {
70018
+ addDeprecatedSuggestion(node, targetSymbol.declarations, node.escapedText);
69946
70019
  }
69947
70020
  var declaration = localOrExportSymbol.valueDeclaration;
69948
70021
  if (declaration && localOrExportSymbol.flags & 32 /* Class */) {
@@ -72954,7 +73027,7 @@ var ts;
72954
73027
  }
72955
73028
  }
72956
73029
  else {
72957
- if (prop.declarations && getDeclarationNodeFlagsFromSymbol(prop) & 134217728 /* Deprecated */ && isUncalledFunctionReference(node, prop)) {
73030
+ if (isDeprecatedSymbol(prop) && isUncalledFunctionReference(node, prop) && prop.declarations) {
72958
73031
  addDeprecatedSuggestion(right, prop.declarations, right.escapedText);
72959
73032
  }
72960
73033
  checkPropertyNotUsedBeforeDeclaration(prop, node, right);
@@ -74413,7 +74486,7 @@ var ts;
74413
74486
  }
74414
74487
  var diags_3 = max > 1 ? allDiagnostics[minIndex] : ts.flatten(allDiagnostics);
74415
74488
  ts.Debug.assert(diags_3.length > 0, "No errors reported for 3 or fewer overload signatures");
74416
- 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);
74489
+ var chain = ts.chainDiagnosticMessages(ts.map(diags_3, ts.createDiagnosticMessageChainFromDiagnostic), ts.Diagnostics.No_overload_matches_this_call);
74417
74490
  // 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
74418
74491
  // arrays and the emptyArray singleton where possible, which is decidedly not what we want while we're still constructing this diagnostic
74419
74492
  var related = __spreadArray([], ts.flatMap(diags_3, function (d) { return d.relatedInformation; }), true);
@@ -82792,16 +82865,15 @@ var ts;
82792
82865
  return ts.nodeIsMissing(expr) ? 0 : evaluateEnumMember(expr, getSymbolOfNode(member.parent), identifier.escapedText);
82793
82866
  case 206 /* ElementAccessExpression */:
82794
82867
  case 205 /* PropertyAccessExpression */:
82795
- var ex = expr;
82796
- if (isConstantMemberAccess(ex)) {
82797
- var type = getTypeOfExpression(ex.expression);
82868
+ if (isConstantMemberAccess(expr)) {
82869
+ var type = getTypeOfExpression(expr.expression);
82798
82870
  if (type.symbol && type.symbol.flags & 384 /* Enum */) {
82799
82871
  var name = void 0;
82800
- if (ex.kind === 205 /* PropertyAccessExpression */) {
82801
- name = ex.name.escapedText;
82872
+ if (expr.kind === 205 /* PropertyAccessExpression */) {
82873
+ name = expr.name.escapedText;
82802
82874
  }
82803
82875
  else {
82804
- name = ts.escapeLeadingUnderscores(ts.cast(ex.argumentExpression, ts.isLiteralExpression).text);
82876
+ name = ts.escapeLeadingUnderscores(ts.cast(expr.argumentExpression, ts.isLiteralExpression).text);
82805
82877
  }
82806
82878
  return evaluateEnumMember(expr, type.symbol, name);
82807
82879
  }
@@ -82829,6 +82901,10 @@ var ts;
82829
82901
  }
82830
82902
  }
82831
82903
  function isConstantMemberAccess(node) {
82904
+ var type = getTypeOfExpression(node);
82905
+ if (type === errorType) {
82906
+ return false;
82907
+ }
82832
82908
  return node.kind === 79 /* Identifier */ ||
82833
82909
  node.kind === 205 /* PropertyAccessExpression */ && isConstantMemberAccess(node.expression) ||
82834
82910
  node.kind === 206 /* ElementAccessExpression */ && isConstantMemberAccess(node.expression) &&
@@ -83123,7 +83199,6 @@ var ts;
83123
83199
  return true;
83124
83200
  }
83125
83201
  function checkAliasSymbol(node) {
83126
- var _a;
83127
83202
  var symbol = getSymbolOfNode(node);
83128
83203
  var target = resolveAlias(symbol);
83129
83204
  if (target !== unknownSymbol) {
@@ -83179,10 +83254,45 @@ var ts;
83179
83254
  }
83180
83255
  }
83181
83256
  }
83182
- if (ts.isImportSpecifier(node) && ((_a = target.declarations) === null || _a === void 0 ? void 0 : _a.every(function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); }))) {
83183
- addDeprecatedSuggestion(node.name, target.declarations, symbol.escapedName);
83257
+ if (ts.isImportSpecifier(node)) {
83258
+ var targetSymbol = checkDeprecatedAliasedSymbol(symbol, node);
83259
+ if (isDeprecatedAliasedSymbol(targetSymbol) && targetSymbol.declarations) {
83260
+ addDeprecatedSuggestion(node, targetSymbol.declarations, targetSymbol.escapedName);
83261
+ }
83262
+ }
83263
+ }
83264
+ }
83265
+ function isDeprecatedAliasedSymbol(symbol) {
83266
+ return !!symbol.declarations && ts.every(symbol.declarations, function (d) { return !!(ts.getCombinedNodeFlags(d) & 134217728 /* Deprecated */); });
83267
+ }
83268
+ function checkDeprecatedAliasedSymbol(symbol, location) {
83269
+ if (!(symbol.flags & 2097152 /* Alias */))
83270
+ return symbol;
83271
+ var targetSymbol = resolveAlias(symbol);
83272
+ if (targetSymbol === unknownSymbol)
83273
+ return targetSymbol;
83274
+ while (symbol.flags & 2097152 /* Alias */) {
83275
+ var target = getImmediateAliasedSymbol(symbol);
83276
+ if (target) {
83277
+ if (target === targetSymbol)
83278
+ break;
83279
+ if (target.declarations && ts.length(target.declarations)) {
83280
+ if (isDeprecatedAliasedSymbol(target)) {
83281
+ addDeprecatedSuggestion(location, target.declarations, target.escapedName);
83282
+ break;
83283
+ }
83284
+ else {
83285
+ if (symbol === targetSymbol)
83286
+ break;
83287
+ symbol = target;
83288
+ }
83289
+ }
83290
+ }
83291
+ else {
83292
+ break;
83184
83293
  }
83185
83294
  }
83295
+ return targetSymbol;
83186
83296
  }
83187
83297
  function checkImportBinding(node) {
83188
83298
  checkCollisionsForDeclarationName(node, node.name);
@@ -115841,14 +115951,14 @@ var ts;
115841
115951
  redirectTargetsMap.add(fileFromPackageId.path, fileName);
115842
115952
  addFileToFilesByName(dupFile, path, redirectedPath);
115843
115953
  addFileIncludeReason(dupFile, reason);
115844
- sourceFileToPackageName.set(path, packageId.name);
115954
+ sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
115845
115955
  processingOtherFiles.push(dupFile);
115846
115956
  return dupFile;
115847
115957
  }
115848
115958
  else if (file) {
115849
115959
  // This is the first source file to have this packageId.
115850
115960
  packageIdToSourceFile.set(packageIdKey, file);
115851
- sourceFileToPackageName.set(path, packageId.name);
115961
+ sourceFileToPackageName.set(path, ts.packageIdToPackageName(packageId));
115852
115962
  }
115853
115963
  }
115854
115964
  addFileToFilesByName(file, path, redirectedPath);
@@ -119987,7 +120097,7 @@ var ts;
119987
120097
  if (!host.fileExists || !host.readFile) {
119988
120098
  return undefined;
119989
120099
  }
119990
- var parts = getNodeModulePathParts(path);
120100
+ var parts = ts.getNodeModulePathParts(path);
119991
120101
  if (!parts) {
119992
120102
  return undefined;
119993
120103
  }
@@ -120110,58 +120220,6 @@ var ts;
120110
120220
  }
120111
120221
  }
120112
120222
  }
120113
- function getNodeModulePathParts(fullPath) {
120114
- // If fullPath can't be valid module file within node_modules, returns undefined.
120115
- // Example of expected pattern: /base/path/node_modules/[@scope/otherpackage/@otherscope/node_modules/]package/[subdirectory/]file.js
120116
- // Returns indices: ^ ^ ^ ^
120117
- var topLevelNodeModulesIndex = 0;
120118
- var topLevelPackageNameIndex = 0;
120119
- var packageRootIndex = 0;
120120
- var fileNameIndex = 0;
120121
- var States;
120122
- (function (States) {
120123
- States[States["BeforeNodeModules"] = 0] = "BeforeNodeModules";
120124
- States[States["NodeModules"] = 1] = "NodeModules";
120125
- States[States["Scope"] = 2] = "Scope";
120126
- States[States["PackageContent"] = 3] = "PackageContent";
120127
- })(States || (States = {}));
120128
- var partStart = 0;
120129
- var partEnd = 0;
120130
- var state = 0 /* BeforeNodeModules */;
120131
- while (partEnd >= 0) {
120132
- partStart = partEnd;
120133
- partEnd = fullPath.indexOf("/", partStart + 1);
120134
- switch (state) {
120135
- case 0 /* BeforeNodeModules */:
120136
- if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
120137
- topLevelNodeModulesIndex = partStart;
120138
- topLevelPackageNameIndex = partEnd;
120139
- state = 1 /* NodeModules */;
120140
- }
120141
- break;
120142
- case 1 /* NodeModules */:
120143
- case 2 /* Scope */:
120144
- if (state === 1 /* NodeModules */ && fullPath.charAt(partStart + 1) === "@") {
120145
- state = 2 /* Scope */;
120146
- }
120147
- else {
120148
- packageRootIndex = partEnd;
120149
- state = 3 /* PackageContent */;
120150
- }
120151
- break;
120152
- case 3 /* PackageContent */:
120153
- if (fullPath.indexOf(ts.nodeModulesPathPart, partStart) === partStart) {
120154
- state = 1 /* NodeModules */;
120155
- }
120156
- else {
120157
- state = 3 /* PackageContent */;
120158
- }
120159
- break;
120160
- }
120161
- }
120162
- fileNameIndex = partStart;
120163
- return state > 1 /* NodeModules */ ? { topLevelNodeModulesIndex: topLevelNodeModulesIndex, topLevelPackageNameIndex: topLevelPackageNameIndex, packageRootIndex: packageRootIndex, fileNameIndex: fileNameIndex } : undefined;
120164
- }
120165
120223
  function getPathRelativeToRootDirs(path, rootDirs, getCanonicalFileName) {
120166
120224
  return ts.firstDefined(rootDirs, function (rootDir) {
120167
120225
  var relativePath = getRelativePathIfInDirectory(path, rootDir, getCanonicalFileName);
@@ -126508,11 +126566,11 @@ var ts;
126508
126566
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
126509
126567
  }
126510
126568
  ts.firstOrOnly = firstOrOnly;
126511
- function getNameForExportedSymbol(symbol, scriptTarget) {
126569
+ function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
126512
126570
  if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
126513
126571
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
126514
126572
  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; })
126515
- || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget);
126573
+ || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
126516
126574
  }
126517
126575
  return symbol.name;
126518
126576
  }
@@ -126631,6 +126689,17 @@ var ts;
126631
126689
  var exportInfoId = 1;
126632
126690
  var exportInfo = ts.createMultiMap();
126633
126691
  var symbols = new ts.Map();
126692
+ /**
126693
+ * Key: node_modules package name (no @types).
126694
+ * Value: path to deepest node_modules folder seen that is
126695
+ * both visible to `usableByFileName` and contains the package.
126696
+ *
126697
+ * Later, we can see if a given SymbolExportInfo is shadowed by
126698
+ * a another installation of the same package in a deeper
126699
+ * node_modules folder by seeing if its path starts with the
126700
+ * value stored here.
126701
+ */
126702
+ var packages = new ts.Map();
126634
126703
  var usableByFileName;
126635
126704
  var cache = {
126636
126705
  isUsableByFile: function (importingFile) { return importingFile === usableByFileName; },
@@ -126640,11 +126709,32 @@ var ts;
126640
126709
  symbols.clear();
126641
126710
  usableByFileName = undefined;
126642
126711
  },
126643
- add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, scriptTarget, checker) {
126712
+ add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, checker) {
126644
126713
  if (importingFile !== usableByFileName) {
126645
126714
  cache.clear();
126646
126715
  usableByFileName = importingFile;
126647
126716
  }
126717
+ var packageName;
126718
+ if (moduleFile) {
126719
+ var nodeModulesPathParts = ts.getNodeModulePathParts(moduleFile.fileName);
126720
+ if (nodeModulesPathParts) {
126721
+ var topLevelNodeModulesIndex = nodeModulesPathParts.topLevelNodeModulesIndex, topLevelPackageNameIndex = nodeModulesPathParts.topLevelPackageNameIndex, packageRootIndex = nodeModulesPathParts.packageRootIndex;
126722
+ packageName = ts.unmangleScopedPackageName(ts.getPackageNameFromTypesPackageName(moduleFile.fileName.substring(topLevelPackageNameIndex + 1, packageRootIndex)));
126723
+ if (ts.startsWith(importingFile, moduleFile.path.substring(0, topLevelNodeModulesIndex))) {
126724
+ var prevDeepestNodeModulesPath = packages.get(packageName);
126725
+ var nodeModulesPath = moduleFile.fileName.substring(0, topLevelPackageNameIndex);
126726
+ if (prevDeepestNodeModulesPath) {
126727
+ var prevDeepestNodeModulesIndex = prevDeepestNodeModulesPath.indexOf(ts.nodeModulesPathPart);
126728
+ if (topLevelNodeModulesIndex > prevDeepestNodeModulesIndex) {
126729
+ packages.set(packageName, nodeModulesPath);
126730
+ }
126731
+ }
126732
+ else {
126733
+ packages.set(packageName, nodeModulesPath);
126734
+ }
126735
+ }
126736
+ }
126737
+ }
126648
126738
  var isDefault = exportKind === 1 /* Default */;
126649
126739
  var namedSymbol = isDefault && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126650
126740
  // 1. A named export must be imported by its key in `moduleSymbol.exports` or `moduleSymbol.members`.
@@ -126656,7 +126746,7 @@ var ts;
126656
126746
  // get a better name.
126657
126747
  var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126658
126748
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
126659
- : ts.getNameForExportedSymbol(namedSymbol, scriptTarget);
126749
+ : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
126660
126750
  var moduleName = ts.stripQuotes(moduleSymbol.name);
126661
126751
  var id = exportInfoId++;
126662
126752
  var target = ts.skipAlias(symbol, checker);
@@ -126671,6 +126761,7 @@ var ts;
126671
126761
  moduleName: moduleName,
126672
126762
  moduleFile: moduleFile,
126673
126763
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
126764
+ packageName: packageName,
126674
126765
  exportKind: exportKind,
126675
126766
  targetFlags: target.flags,
126676
126767
  isFromPackageJson: isFromPackageJson,
@@ -126689,7 +126780,17 @@ var ts;
126689
126780
  return;
126690
126781
  exportInfo.forEach(function (info, key) {
126691
126782
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
126692
- action(info.map(rehydrateCachedInfo), symbolName, !!ambientModuleName, key);
126783
+ var rehydrated = info.map(rehydrateCachedInfo);
126784
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126785
+ if (filtered.length) {
126786
+ action(filtered, function (preferCapitalized) {
126787
+ var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
126788
+ var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126789
+ return preferCapitalized
126790
+ ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
126791
+ : symbolName;
126792
+ }, !!ambientModuleName, key);
126793
+ }
126693
126794
  });
126694
126795
  },
126695
126796
  releaseSymbols: function () {
@@ -126789,6 +126890,12 @@ var ts;
126789
126890
  }
126790
126891
  return true;
126791
126892
  }
126893
+ function isNotShadowedByDeeperNodeModulesPackage(info, packageName) {
126894
+ if (!packageName || !info.moduleFileName)
126895
+ return true;
126896
+ var packageDeepestNodeModulesPath = packages.get(packageName);
126897
+ return !packageDeepestNodeModulesPath || ts.startsWith(info.moduleFileName, packageDeepestNodeModulesPath);
126898
+ }
126792
126899
  }
126793
126900
  ts.createCacheableExportInfoMap = createCacheableExportInfoMap;
126794
126901
  function isImportableFile(program, from, to, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) {
@@ -126871,7 +126978,6 @@ var ts;
126871
126978
  }
126872
126979
  (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
126873
126980
  var compilerOptions = program.getCompilerOptions();
126874
- var scriptTarget = ts.getEmitScriptTarget(compilerOptions);
126875
126981
  var moduleCount = 0;
126876
126982
  forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
126877
126983
  if (++moduleCount % 100 === 0)
@@ -126882,11 +126988,11 @@ var ts;
126882
126988
  // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
126883
126989
  // can cause it to happen: see 'completionsImport_mergedReExport.ts'
126884
126990
  if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
126885
- cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, scriptTarget, checker);
126991
+ cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
126886
126992
  }
126887
126993
  checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
126888
126994
  if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
126889
- cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, scriptTarget, checker);
126995
+ cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
126890
126996
  }
126891
126997
  });
126892
126998
  });
@@ -128960,6 +129066,8 @@ var ts;
128960
129066
  CompletionSource["ThisProperty"] = "ThisProperty/";
128961
129067
  /** Auto-import that comes attached to a class member snippet */
128962
129068
  CompletionSource["ClassMemberSnippet"] = "ClassMemberSnippet/";
129069
+ /** A type-only import that needs to be promoted in order to be used at the completion location */
129070
+ CompletionSource["TypeOnlyAlias"] = "TypeOnlyAlias/";
128963
129071
  })(CompletionSource = Completions.CompletionSource || (Completions.CompletionSource = {}));
128964
129072
  var SymbolOriginInfoKind;
128965
129073
  (function (SymbolOriginInfoKind) {
@@ -128969,6 +129077,7 @@ var ts;
128969
129077
  SymbolOriginInfoKind[SymbolOriginInfoKind["Promise"] = 8] = "Promise";
128970
129078
  SymbolOriginInfoKind[SymbolOriginInfoKind["Nullable"] = 16] = "Nullable";
128971
129079
  SymbolOriginInfoKind[SymbolOriginInfoKind["ResolvedExport"] = 32] = "ResolvedExport";
129080
+ SymbolOriginInfoKind[SymbolOriginInfoKind["TypeOnlyAlias"] = 64] = "TypeOnlyAlias";
128972
129081
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberNoExport"] = 2] = "SymbolMemberNoExport";
128973
129082
  SymbolOriginInfoKind[SymbolOriginInfoKind["SymbolMemberExport"] = 6] = "SymbolMemberExport";
128974
129083
  })(SymbolOriginInfoKind || (SymbolOriginInfoKind = {}));
@@ -128996,6 +129105,9 @@ var ts;
128996
129105
  function originIsNullableMember(origin) {
128997
129106
  return !!(origin.kind & 16 /* Nullable */);
128998
129107
  }
129108
+ function originIsTypeOnlyAlias(origin) {
129109
+ return !!(origin && origin.kind & 64 /* TypeOnlyAlias */);
129110
+ }
128999
129111
  var KeywordCompletionFilters;
129000
129112
  (function (KeywordCompletionFilters) {
129001
129113
  KeywordCompletionFilters[KeywordCompletionFilters["None"] = 0] = "None";
@@ -129094,7 +129206,7 @@ var ts;
129094
129206
  }
129095
129207
  switch (completionData.kind) {
129096
129208
  case 0 /* Data */:
129097
- var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext);
129209
+ var response = completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position);
129098
129210
  if (response === null || response === void 0 ? void 0 : response.isIncomplete) {
129099
129211
  incompleteCompletionsCache === null || incompleteCompletionsCache === void 0 ? void 0 : incompleteCompletionsCache.set(response);
129100
129212
  }
@@ -129214,7 +129326,7 @@ var ts;
129214
129326
  // StringLiteralLike locations are handled separately in stringCompletions.ts
129215
129327
  return (location === null || location === void 0 ? void 0 : location.kind) === 79 /* Identifier */ ? ts.createTextSpanFromNode(location) : undefined;
129216
129328
  }
129217
- function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext) {
129329
+ function completionInfoFromData(sourceFile, host, program, compilerOptions, log, completionData, preferences, formatContext, position) {
129218
129330
  var symbols = completionData.symbols, contextToken = completionData.contextToken, completionKind = completionData.completionKind, isInSnippetScope = completionData.isInSnippetScope, isNewIdentifierLocation = completionData.isNewIdentifierLocation, location = completionData.location, propertyAccessToConvert = completionData.propertyAccessToConvert, keywordFilters = completionData.keywordFilters, literals = completionData.literals, symbolToOriginInfoMap = completionData.symbolToOriginInfoMap, recommendedCompletion = completionData.recommendedCompletion, isJsxInitializer = completionData.isJsxInitializer, isTypeOnlyLocation = completionData.isTypeOnlyLocation, isJsxIdentifierExpected = completionData.isJsxIdentifierExpected, isRightOfOpenTag = completionData.isRightOfOpenTag, importCompletionNode = completionData.importCompletionNode, insideJsDocTagTypeExpression = completionData.insideJsDocTagTypeExpression, symbolToSortTextIdMap = completionData.symbolToSortTextIdMap, hasUnresolvedAutoImports = completionData.hasUnresolvedAutoImports;
129219
129331
  // Verify if the file is JSX language variant
129220
129332
  if (ts.getLanguageVariant(sourceFile.scriptKind) === 1 /* JSX */) {
@@ -129227,7 +129339,7 @@ var ts;
129227
129339
  if (isUncheckedFile(sourceFile, compilerOptions)) {
129228
129340
  var uniqueNames = getCompletionEntriesFromSymbols(symbols, entries,
129229
129341
  /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
129230
- getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries); // TODO: GH#18217
129342
+ getJSCompletionEntries(sourceFile, location.pos, uniqueNames, ts.getEmitScriptTarget(compilerOptions), entries);
129231
129343
  }
129232
129344
  else {
129233
129345
  if (!isNewIdentifierLocation && (!symbols || symbols.length === 0) && keywordFilters === 0 /* None */) {
@@ -129237,16 +129349,23 @@ var ts;
129237
129349
  /*replacementToken*/ undefined, contextToken, location, sourceFile, host, program, ts.getEmitScriptTarget(compilerOptions), log, completionKind, preferences, compilerOptions, formatContext, isTypeOnlyLocation, propertyAccessToConvert, isJsxIdentifierExpected, isJsxInitializer, importCompletionNode, recommendedCompletion, symbolToOriginInfoMap, symbolToSortTextIdMap, isJsxIdentifierExpected, isRightOfOpenTag);
129238
129350
  }
129239
129351
  if (keywordFilters !== 0 /* None */) {
129240
- var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
129352
+ var entryNames_1 = new ts.Set(entries.map(function (e) { return e.name; }));
129241
129353
  for (var _i = 0, _a = getKeywordCompletions(keywordFilters, !insideJsDocTagTypeExpression && ts.isSourceFileJS(sourceFile)); _i < _a.length; _i++) {
129242
129354
  var keywordEntry = _a[_i];
129243
- if (!entryNames.has(keywordEntry.name)) {
129355
+ if (!entryNames_1.has(keywordEntry.name)) {
129244
129356
  ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
129245
129357
  }
129246
129358
  }
129247
129359
  }
129248
- for (var _b = 0, literals_1 = literals; _b < literals_1.length; _b++) {
129249
- var literal = literals_1[_b];
129360
+ var entryNames = new ts.Set(entries.map(function (e) { return e.name; }));
129361
+ for (var _b = 0, _c = getContextualKeywords(contextToken, position); _b < _c.length; _b++) {
129362
+ var keywordEntry = _c[_b];
129363
+ if (!entryNames.has(keywordEntry.name)) {
129364
+ ts.insertSorted(entries, keywordEntry, compareCompletionEntries, /*allowDuplicates*/ true);
129365
+ }
129366
+ }
129367
+ for (var _d = 0, literals_1 = literals; _d < literals_1.length; _d++) {
129368
+ var literal = literals_1[_d];
129250
129369
  ts.insertSorted(entries, createCompletionEntryForLiteral(sourceFile, preferences, literal), compareCompletionEntries, /*allowDuplicates*/ true);
129251
129370
  }
129252
129371
  return {
@@ -129400,6 +129519,9 @@ var ts;
129400
129519
  isSnippet = preferences.includeCompletionsWithSnippetText ? true : undefined;
129401
129520
  }
129402
129521
  }
129522
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
129523
+ hasAction = true;
129524
+ }
129403
129525
  if (preferences.includeCompletionsWithClassMemberSnippets &&
129404
129526
  preferences.includeCompletionsWithInsertText &&
129405
129527
  completionKind === 3 /* MemberLike */ &&
@@ -129744,6 +129866,9 @@ var ts;
129744
129866
  if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 1 /* ThisType */) {
129745
129867
  return CompletionSource.ThisProperty;
129746
129868
  }
129869
+ if ((origin === null || origin === void 0 ? void 0 : origin.kind) === 64 /* TypeOnlyAlias */) {
129870
+ return CompletionSource.TypeOnlyAlias;
129871
+ }
129747
129872
  }
129748
129873
  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) {
129749
129874
  var _a;
@@ -129771,7 +129896,7 @@ var ts;
129771
129896
  continue;
129772
129897
  }
129773
129898
  /** True for locals; false for globals, module exports from other files, `this.` completions. */
129774
- var shouldShadowLaterSymbols = !origin && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
129899
+ var shouldShadowLaterSymbols = (!origin || originIsTypeOnlyAlias(origin)) && !(symbol.parent === undefined && !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === location.getSourceFile(); }));
129775
129900
  uniques.set(name, shouldShadowLaterSymbols);
129776
129901
  ts.insertSorted(entries, entry, compareCompletionEntries, /*allowDuplicates*/ true);
129777
129902
  }
@@ -129784,6 +129909,7 @@ var ts;
129784
129909
  add: function (name) { return uniques.set(name, true); },
129785
129910
  };
129786
129911
  function shouldIncludeSymbol(symbol, symbolToSortTextIdMap) {
129912
+ var allFlags = symbol.flags;
129787
129913
  if (!ts.isSourceFile(location)) {
129788
129914
  // export = /**/ here we want to get all meanings, so any symbol is ok
129789
129915
  if (ts.isExportAssignment(location.parent)) {
@@ -129809,11 +129935,10 @@ var ts;
129809
129935
  || symbolToSortTextIdMap[ts.getSymbolId(symbolOrigin)] === 11 /* LocationPriority */)) {
129810
129936
  return false;
129811
129937
  }
129812
- // Continue with origin symbol
129813
- symbol = symbolOrigin;
129938
+ allFlags |= ts.getCombinedLocalAndExportSymbolFlags(symbolOrigin);
129814
129939
  // import m = /**/ <-- It can only access namespace (if typing import = x. this would get member symbols and not namespace)
129815
129940
  if (ts.isInRightSideOfInternalImportEqualsDeclaration(location)) {
129816
- return !!(symbol.flags & 1920 /* Namespace */);
129941
+ return !!(allFlags & 1920 /* Namespace */);
129817
129942
  }
129818
129943
  if (isTypeOnlyLocation) {
129819
129944
  // It's a type, but you can reach it by namespace.type as well
@@ -129821,7 +129946,7 @@ var ts;
129821
129946
  }
129822
129947
  }
129823
129948
  // expressions are value space (which includes the value namespaces)
129824
- return !!(ts.getCombinedLocalAndExportSymbolFlags(symbol) & 111551 /* Value */);
129949
+ return !!(allFlags & 111551 /* Value */);
129825
129950
  }
129826
129951
  }
129827
129952
  Completions.getCompletionEntriesFromSymbols = getCompletionEntriesFromSymbols;
@@ -129955,8 +130080,7 @@ var ts;
129955
130080
  Completions.createCompletionDetails = createCompletionDetails;
129956
130081
  function getCompletionEntryCodeActionsAndSourceDisplay(name, location, contextToken, origin, symbol, program, host, compilerOptions, sourceFile, position, previousToken, formatContext, preferences, data, source) {
129957
130082
  if (data === null || data === void 0 ? void 0 : data.moduleSpecifier) {
129958
- var _a = getRelevantTokens(position, sourceFile), contextToken_3 = _a.contextToken, previousToken_2 = _a.previousToken;
129959
- if (previousToken_2 && getImportStatementCompletionInfo(contextToken_3 || previousToken_2).replacementNode) {
130083
+ if (previousToken && getImportStatementCompletionInfo(contextToken || previousToken).replacementNode) {
129960
130084
  // Import statement completion: 'import c|'
129961
130085
  return { codeActions: undefined, sourceDisplay: [ts.textPart(data.moduleSpecifier)] };
129962
130086
  }
@@ -129974,13 +130098,19 @@ var ts;
129974
130098
  };
129975
130099
  }
129976
130100
  }
130101
+ if (originIsTypeOnlyAlias(origin)) {
130102
+ var codeAction_1 = ts.codefix.getPromoteTypeOnlyCompletionAction(sourceFile, origin.declaration.name, program, host, formatContext, preferences);
130103
+ ts.Debug.assertIsDefined(codeAction_1, "Expected to have a code action for promoting type-only alias");
130104
+ return { codeActions: [codeAction_1], sourceDisplay: undefined };
130105
+ }
129977
130106
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
129978
130107
  return { codeActions: undefined, sourceDisplay: undefined };
129979
130108
  }
129980
130109
  var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
129981
130110
  var moduleSymbol = origin.moduleSymbol;
129982
130111
  var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
129983
- 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;
130112
+ var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
130113
+ 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;
129984
130114
  ts.Debug.assert(!(data === null || data === void 0 ? void 0 : data.moduleSpecifier) || moduleSpecifier === data.moduleSpecifier);
129985
130115
  return { sourceDisplay: [ts.textPart(moduleSpecifier)], codeActions: [codeAction] };
129986
130116
  }
@@ -130650,21 +130780,29 @@ var ts;
130650
130780
  var scopeNode = getScopeNode(contextToken, adjustedPosition, sourceFile) || sourceFile;
130651
130781
  isInSnippetScope = isSnippetScope(scopeNode);
130652
130782
  var symbolMeanings = (isTypeOnlyLocation ? 0 /* None */ : 111551 /* Value */) | 788968 /* Type */ | 1920 /* Namespace */ | 2097152 /* Alias */;
130783
+ var typeOnlyAliasNeedsPromotion = previousToken && !ts.isValidTypeOnlyAliasUseSite(previousToken);
130653
130784
  symbols = ts.concatenate(symbols, typeChecker.getSymbolsInScope(scopeNode, symbolMeanings));
130654
130785
  ts.Debug.assertEachIsDefined(symbols, "getSymbolsInScope() should all be defined");
130655
- for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
130656
- var symbol = symbols_1[_i];
130786
+ for (var i = 0; i < symbols.length; i++) {
130787
+ var symbol = symbols[i];
130657
130788
  if (!typeChecker.isArgumentsSymbol(symbol) &&
130658
130789
  !ts.some(symbol.declarations, function (d) { return d.getSourceFile() === sourceFile; })) {
130659
130790
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 15 /* GlobalsOrKeywords */;
130660
130791
  }
130792
+ if (typeOnlyAliasNeedsPromotion && !(symbol.flags & 111551 /* Value */)) {
130793
+ var typeOnlyAliasDeclaration = symbol.declarations && ts.find(symbol.declarations, ts.isTypeOnlyImportOrExportDeclaration);
130794
+ if (typeOnlyAliasDeclaration) {
130795
+ var origin = { kind: 64 /* TypeOnlyAlias */, declaration: typeOnlyAliasDeclaration };
130796
+ symbolToOriginInfoMap[i] = origin;
130797
+ }
130798
+ }
130661
130799
  }
130662
130800
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
130663
130801
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 303 /* SourceFile */) {
130664
130802
  var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
130665
130803
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
130666
- for (var _a = 0, _b = getPropertiesForCompletion(thisType, typeChecker); _a < _b.length; _a++) {
130667
- var symbol = _b[_a];
130804
+ for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
130805
+ var symbol = _a[_i];
130668
130806
  symbolToOriginInfoMap[symbols.length] = { kind: 1 /* ThisType */ };
130669
130807
  symbols.push(symbol);
130670
130808
  symbolToSortTextIdMap[ts.getSymbolId(symbol)] = 14 /* SuggestedClassMembers */;
@@ -130767,7 +130905,8 @@ var ts;
130767
130905
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
130768
130906
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
130769
130907
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
130770
- exportInfo.forEach(sourceFile.path, function (info, symbolName, isFromAmbientModule, exportMapKey) {
130908
+ exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
130909
+ var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
130771
130910
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
130772
130911
  return;
130773
130912
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
@@ -130777,6 +130916,10 @@ var ts;
130777
130916
  return;
130778
130917
  if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
130779
130918
  return;
130919
+ // Do not try to auto-import something with a lowercase first letter for a JSX tag
130920
+ var firstChar = symbolName.charCodeAt(0);
130921
+ if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
130922
+ return;
130780
130923
  var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
130781
130924
  if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
130782
130925
  var defaultExportInfo = ts.find(info, isImportableExportInfo);
@@ -130853,16 +130996,19 @@ var ts;
130853
130996
  return true;
130854
130997
  }
130855
130998
  if (contextToken.kind === 31 /* GreaterThanToken */ && contextToken.parent) {
130999
+ // <Component<string> /**/ />
131000
+ // <Component<string> /**/ ><Component>
131001
+ // - contextToken: GreaterThanToken (before cursor)
131002
+ // - location: JsxSelfClosingElement or JsxOpeningElement
131003
+ // - contextToken.parent === location
131004
+ if (location === contextToken.parent && (location.kind === 279 /* JsxOpeningElement */ || location.kind === 278 /* JsxSelfClosingElement */)) {
131005
+ return false;
131006
+ }
130856
131007
  if (contextToken.parent.kind === 279 /* JsxOpeningElement */) {
130857
- // Two possibilities:
130858
- // 1. <div>/**/
130859
- // - contextToken: GreaterThanToken (before cursor)
130860
- // - location: JSXElement
130861
- // - different parents (JSXOpeningElement, JSXElement)
130862
- // 2. <Component<string> /**/>
130863
- // - contextToken: GreaterThanToken (before cursor)
130864
- // - location: GreaterThanToken (after cursor)
130865
- // - same parent (JSXOpeningElement)
131008
+ // <div>/**/
131009
+ // - contextToken: GreaterThanToken (before cursor)
131010
+ // - location: JSXElement
131011
+ // - different parents (JSXOpeningElement, JSXElement)
130866
131012
  return location.parent.kind !== 279 /* JsxOpeningElement */;
130867
131013
  }
130868
131014
  if (contextToken.parent.kind === 280 /* JsxClosingElement */ || contextToken.parent.kind === 278 /* JsxSelfClosingElement */) {
@@ -131769,6 +131915,34 @@ var ts;
131769
131915
  function keywordForNode(node) {
131770
131916
  return ts.isIdentifier(node) ? node.originalKeywordKind || 0 /* Unknown */ : node.kind;
131771
131917
  }
131918
+ function getContextualKeywords(contextToken, position) {
131919
+ var entries = [];
131920
+ /**
131921
+ * An `AssertClause` can come after an import declaration:
131922
+ * import * from "foo" |
131923
+ * import "foo" |
131924
+ * or after a re-export declaration that has a module specifier:
131925
+ * export { foo } from "foo" |
131926
+ * Source: https://tc39.es/proposal-import-assertions/
131927
+ */
131928
+ if (contextToken) {
131929
+ var file = contextToken.getSourceFile();
131930
+ var parent = contextToken.parent;
131931
+ var tokenLine = file.getLineAndCharacterOfPosition(contextToken.end).line;
131932
+ var currentLine = file.getLineAndCharacterOfPosition(position).line;
131933
+ if ((ts.isImportDeclaration(parent) || ts.isExportDeclaration(parent) && parent.moduleSpecifier)
131934
+ && contextToken === parent.moduleSpecifier
131935
+ && tokenLine === currentLine) {
131936
+ entries.push({
131937
+ name: ts.tokenToString(129 /* AssertKeyword */),
131938
+ kind: "keyword" /* keyword */,
131939
+ kindModifiers: "" /* none */,
131940
+ sortText: SortText.GlobalsOrKeywords,
131941
+ });
131942
+ }
131943
+ }
131944
+ return entries;
131945
+ }
131772
131946
  /** Get the corresponding JSDocTag node if the position is in a jsDoc comment */
131773
131947
  function getJsDocTagAtPosition(node, position) {
131774
131948
  return ts.findAncestor(node, function (n) {
@@ -132063,10 +132237,14 @@ var ts;
132063
132237
  /** True if symbol is a type or a module containing at least one type. */
132064
132238
  function symbolCanBeReferencedAtTypeLocation(symbol, checker, seenModules) {
132065
132239
  if (seenModules === void 0) { seenModules = new ts.Map(); }
132066
- var sym = ts.skipAlias(symbol.exportSymbol || symbol, checker);
132067
- return !!(sym.flags & 788968 /* Type */) || checker.isUnknownSymbol(sym) ||
132068
- !!(sym.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(sym)) &&
132069
- checker.getExportsOfModule(sym).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132240
+ // Since an alias can be merged with a local declaration, we need to test both the alias and its target.
132241
+ // This code used to just test the result of `skipAlias`, but that would ignore any locally introduced meanings.
132242
+ return nonAliasCanBeReferencedAtTypeLocation(symbol) || nonAliasCanBeReferencedAtTypeLocation(ts.skipAlias(symbol.exportSymbol || symbol, checker));
132243
+ function nonAliasCanBeReferencedAtTypeLocation(symbol) {
132244
+ return !!(symbol.flags & 788968 /* Type */) || checker.isUnknownSymbol(symbol) ||
132245
+ !!(symbol.flags & 1536 /* Module */) && ts.addToSeen(seenModules, ts.getSymbolId(symbol)) &&
132246
+ checker.getExportsOfModule(symbol).some(function (e) { return symbolCanBeReferencedAtTypeLocation(e, checker, seenModules); });
132247
+ }
132070
132248
  }
132071
132249
  function isDeprecated(symbol, checker) {
132072
132250
  var declarations = ts.skipAlias(symbol, checker).declarations;
@@ -134320,8 +134498,8 @@ var ts;
134320
134498
  var sourceId = ts.getNodeId(sourceFile);
134321
134499
  var seenSymbols = this.sourceFileToSeenSymbols[sourceId] || (this.sourceFileToSeenSymbols[sourceId] = new ts.Set());
134322
134500
  var anyNewSymbols = false;
134323
- for (var _i = 0, symbols_2 = symbols; _i < symbols_2.length; _i++) {
134324
- var sym = symbols_2[_i];
134501
+ for (var _i = 0, symbols_1 = symbols; _i < symbols_1.length; _i++) {
134502
+ var sym = symbols_1[_i];
134325
134503
  anyNewSymbols = ts.tryAddToSet(seenSymbols, ts.getSymbolId(sym)) || anyNewSymbols;
134326
134504
  }
134327
134505
  return anyNewSymbols;
@@ -141281,6 +141459,8 @@ var ts;
141281
141459
  }
141282
141460
  if (flags & 16 /* Function */)
141283
141461
  return isLocalVariableOrFunction(symbol) ? "local function" /* localFunctionElement */ : "function" /* functionElement */;
141462
+ // FIXME: getter and setter use the same symbol. And it is rare to use only setter without getter, so in most cases the symbol always has getter flag.
141463
+ // So, even when the location is just on the declaration of setter, this function returns getter.
141284
141464
  if (flags & 32768 /* GetAccessor */)
141285
141465
  return "getter" /* memberGetAccessorElement */;
141286
141466
  if (flags & 65536 /* SetAccessor */)
@@ -141367,9 +141547,24 @@ var ts;
141367
141547
  }
141368
141548
  // Class at constructor site need to be shown as constructor apart from property,method, vars
141369
141549
  if (symbolKind !== "" /* unknown */ || symbolFlags & 32 /* Class */ || symbolFlags & 2097152 /* Alias */) {
141370
- // If it is accessor they are allowed only if location is at name of the accessor
141550
+ // If symbol is accessor, they are allowed only if location is at declaration identifier of the accessor
141371
141551
  if (symbolKind === "getter" /* memberGetAccessorElement */ || symbolKind === "setter" /* memberSetAccessorElement */) {
141372
- symbolKind = "property" /* memberVariableElement */;
141552
+ var declaration = ts.find(symbol.declarations, function (declaration) { return declaration.name === location; });
141553
+ if (declaration) {
141554
+ switch (declaration.kind) {
141555
+ case 171 /* GetAccessor */:
141556
+ symbolKind = "getter" /* memberGetAccessorElement */;
141557
+ break;
141558
+ case 172 /* SetAccessor */:
141559
+ symbolKind = "setter" /* memberSetAccessorElement */;
141560
+ break;
141561
+ default:
141562
+ ts.Debug.assertNever(declaration);
141563
+ }
141564
+ }
141565
+ else {
141566
+ symbolKind = "property" /* memberVariableElement */;
141567
+ }
141373
141568
  }
141374
141569
  var signature = void 0;
141375
141570
  type = isThisExpression ? typeChecker.getTypeAtLocation(location) : typeChecker.getTypeOfSymbolAtLocation(symbol, location);
@@ -141683,6 +141878,8 @@ var ts;
141683
141878
  }
141684
141879
  // For properties, variables and local vars: show the type
141685
141880
  if (symbolKind === "property" /* memberVariableElement */ ||
141881
+ symbolKind === "getter" /* memberGetAccessorElement */ ||
141882
+ symbolKind === "setter" /* memberSetAccessorElement */ ||
141686
141883
  symbolKind === "JSX attribute" /* jsxAttribute */ ||
141687
141884
  symbolFlags & 3 /* Variable */ ||
141688
141885
  symbolKind === "local var" /* localVariableElement */ ||
@@ -141753,7 +141950,7 @@ var ts;
141753
141950
  }
141754
141951
  }
141755
141952
  if (tags.length === 0 && !hasMultipleSignatures) {
141756
- tags = symbol.getJsDocTags(typeChecker);
141953
+ tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
141757
141954
  }
141758
141955
  if (documentation.length === 0 && documentationFromAlias) {
141759
141956
  documentation = documentationFromAlias;
@@ -145173,6 +145370,7 @@ var ts;
145173
145370
  ChangeTracker.prototype.delete = function (sourceFile, node) {
145174
145371
  this.deletedNodes.push({ sourceFile: sourceFile, node: node });
145175
145372
  };
145373
+ /** Stop! Consider using `delete` instead, which has logic for deleting nodes from delimited lists. */
145176
145374
  ChangeTracker.prototype.deleteNode = function (sourceFile, node, options) {
145177
145375
  if (options === void 0) { options = { leadingTriviaOption: LeadingTriviaOption.IncludeAll }; }
145178
145376
  this.deleteRange(sourceFile, getAdjustedRange(sourceFile, node, node, options));
@@ -145576,6 +145774,15 @@ var ts;
145576
145774
  ChangeTracker.prototype.insertExportModifier = function (sourceFile, node) {
145577
145775
  this.insertText(sourceFile, node.getStart(sourceFile), "export ");
145578
145776
  };
145777
+ ChangeTracker.prototype.insertImportSpecifierAtIndex = function (sourceFile, importSpecifier, namedImports, index) {
145778
+ var prevSpecifier = namedImports.elements[index - 1];
145779
+ if (prevSpecifier) {
145780
+ this.insertNodeInListAfter(sourceFile, prevSpecifier, importSpecifier);
145781
+ }
145782
+ else {
145783
+ this.insertNodeBefore(sourceFile, namedImports.elements[0], importSpecifier, !ts.positionsAreOnSameLine(namedImports.elements[0].getStart(), namedImports.parent.parent.getStart(), sourceFile));
145784
+ }
145785
+ };
145579
145786
  /**
145580
145787
  * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
145581
145788
  * i.e. arguments in arguments lists, parameters in parameter lists etc.
@@ -149078,7 +149285,8 @@ var ts;
149078
149285
  ts.Diagnostics.Cannot_find_namespace_0.code,
149079
149286
  ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code,
149080
149287
  ts.Diagnostics._0_only_refers_to_a_type_but_is_being_used_as_a_value_here.code,
149081
- ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code
149288
+ ts.Diagnostics.No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer.code,
149289
+ ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code,
149082
149290
  ];
149083
149291
  codefix.registerCodeFix({
149084
149292
  errorCodes: errorCodes,
@@ -149087,9 +149295,10 @@ var ts;
149087
149295
  var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
149088
149296
  if (!info)
149089
149297
  return undefined;
149090
- var fixes = info.fixes, symbolName = info.symbolName;
149298
+ var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
149091
149299
  var quotePreference = ts.getQuotePreference(sourceFile, preferences);
149092
- return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, program.getCompilerOptions()); });
149300
+ return fixes.map(function (fix) { return codeActionForFix(context, sourceFile, symbolName, fix,
149301
+ /*includeSymbolNameInDescription*/ symbolName !== errorIdentifierText, quotePreference, program.getCompilerOptions()); });
149093
149302
  },
149094
149303
  fixIds: [importFixId],
149095
149304
  getAllCodeActions: function (context) {
@@ -149124,11 +149333,11 @@ var ts;
149124
149333
  var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
149125
149334
  var checker = program.getTypeChecker();
149126
149335
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
149127
- var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, host, program, preferences, useAutoImportProvider);
149336
+ var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
149128
149337
  var useRequire = shouldUseRequire(sourceFile, program);
149129
149338
  var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149130
149339
  if (fix) {
149131
- addImport({ fixes: [fix], symbolName: symbolName });
149340
+ addImport({ fixes: [fix], symbolName: symbolName, errorIdentifierText: undefined });
149132
149341
  }
149133
149342
  }
149134
149343
  function addImport(info) {
@@ -149183,6 +149392,9 @@ var ts;
149183
149392
  }
149184
149393
  break;
149185
149394
  }
149395
+ case 4 /* PromoteTypeOnly */:
149396
+ // Excluding from fix-all
149397
+ break;
149186
149398
  default:
149187
149399
  ts.Debug.assertNever(fix, "fix wasn't never - got kind " + fix.kind);
149188
149400
  }
@@ -149274,6 +149486,7 @@ var ts;
149274
149486
  ImportFixKind[ImportFixKind["JsdocTypeImport"] = 1] = "JsdocTypeImport";
149275
149487
  ImportFixKind[ImportFixKind["AddToExisting"] = 2] = "AddToExisting";
149276
149488
  ImportFixKind[ImportFixKind["AddNew"] = 3] = "AddNew";
149489
+ ImportFixKind[ImportFixKind["PromoteTypeOnly"] = 4] = "PromoteTypeOnly";
149277
149490
  })(ImportFixKind || (ImportFixKind = {}));
149278
149491
  // These should not be combined as bitflags, but are given powers of 2 values to
149279
149492
  // easily detect conflicts between `NotAllowed` and `Required` by giving them a unique sum.
@@ -149285,20 +149498,29 @@ var ts;
149285
149498
  AddAsTypeOnly[AddAsTypeOnly["Required"] = 2] = "Required";
149286
149499
  AddAsTypeOnly[AddAsTypeOnly["NotAllowed"] = 4] = "NotAllowed";
149287
149500
  })(AddAsTypeOnly || (AddAsTypeOnly = {}));
149288
- function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, host, program, formatContext, position, preferences) {
149501
+ function getImportCompletionAction(targetSymbol, moduleSymbol, sourceFile, symbolName, isJsxTagName, host, program, formatContext, position, preferences) {
149289
149502
  var compilerOptions = program.getCompilerOptions();
149290
149503
  var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
149291
149504
  ? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
149292
- : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, host, program, preferences, /*useAutoImportProvider*/ true);
149505
+ : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
149293
149506
  var useRequire = shouldUseRequire(sourceFile, program);
149294
149507
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
149295
149508
  var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
149296
149509
  return {
149297
149510
  moduleSpecifier: fix.moduleSpecifier,
149298
- codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
149511
+ codeAction: codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix,
149512
+ /*includeSymbolNameInDescription*/ false, ts.getQuotePreference(sourceFile, preferences), compilerOptions))
149299
149513
  };
149300
149514
  }
149301
149515
  codefix.getImportCompletionAction = getImportCompletionAction;
149516
+ function getPromoteTypeOnlyCompletionAction(sourceFile, symbolToken, program, host, formatContext, preferences) {
149517
+ var compilerOptions = program.getCompilerOptions();
149518
+ var symbolName = getSymbolName(sourceFile, program.getTypeChecker(), symbolToken, compilerOptions);
149519
+ var fix = getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program);
149520
+ var includeSymbolNameInDescription = symbolName !== symbolToken.text;
149521
+ return fix && codeFixActionToCodeAction(codeActionForFix({ host: host, formatContext: formatContext, preferences: preferences }, sourceFile, symbolName, fix, includeSymbolNameInDescription, 1 /* Double */, compilerOptions));
149522
+ }
149523
+ codefix.getPromoteTypeOnlyCompletionAction = getPromoteTypeOnlyCompletionAction;
149302
149524
  function getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences) {
149303
149525
  ts.Debug.assert(exportInfos.some(function (info) { return info.moduleSymbol === moduleSymbol || info.symbol.parent === moduleSymbol; }), "Some exportInfo should match the specified moduleSymbol");
149304
149526
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(sourceFile, preferences, host);
@@ -149328,7 +149550,7 @@ var ts;
149328
149550
  }
149329
149551
  }
149330
149552
  }
149331
- function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, host, program, preferences, useAutoImportProvider) {
149553
+ function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences, useAutoImportProvider) {
149332
149554
  var result = [];
149333
149555
  var compilerOptions = program.getCompilerOptions();
149334
149556
  var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
@@ -149341,7 +149563,7 @@ var ts;
149341
149563
  return;
149342
149564
  }
149343
149565
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
149344
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
149566
+ if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
149345
149567
  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 });
149346
149568
  }
149347
149569
  for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
@@ -149579,9 +149801,21 @@ var ts;
149579
149801
  }
149580
149802
  function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
149581
149803
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
149582
- var info = errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code
149583
- ? getFixesInfoForUMDImport(context, symbolToken)
149584
- : ts.isIdentifier(symbolToken) ? getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider) : undefined;
149804
+ var info;
149805
+ if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
149806
+ info = getFixesInfoForUMDImport(context, symbolToken);
149807
+ }
149808
+ else if (!ts.isIdentifier(symbolToken)) {
149809
+ return undefined;
149810
+ }
149811
+ else if (errorCode === ts.Diagnostics._0_cannot_be_used_as_a_value_because_it_was_imported_using_import_type.code) {
149812
+ var symbolName_1 = getSymbolName(context.sourceFile, context.program.getTypeChecker(), symbolToken, context.program.getCompilerOptions());
149813
+ var fix = getTypeOnlyPromotionFix(context.sourceFile, symbolToken, symbolName_1, context.program);
149814
+ return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
149815
+ }
149816
+ else {
149817
+ info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
149818
+ }
149585
149819
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
149586
149820
  return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
149587
149821
  }
@@ -149622,6 +149856,7 @@ var ts;
149622
149856
  return 0 /* EqualTo */;
149623
149857
  }
149624
149858
  function getFixesInfoForUMDImport(_a, token) {
149859
+ var _b;
149625
149860
  var sourceFile = _a.sourceFile, program = _a.program, host = _a.host, preferences = _a.preferences;
149626
149861
  var checker = program.getTypeChecker();
149627
149862
  var umdSymbol = getUmdSymbol(token, checker);
@@ -149632,7 +149867,7 @@ var ts;
149632
149867
  var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
149633
149868
  var useRequire = shouldUseRequire(sourceFile, program);
149634
149869
  var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
149635
- return { fixes: fixes, symbolName: symbolName };
149870
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
149636
149871
  }
149637
149872
  function getUmdSymbol(token, checker) {
149638
149873
  // try the identifier to see if it is the umd symbol
@@ -149698,12 +149933,22 @@ var ts;
149698
149933
  ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
149699
149934
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
149700
149935
  var useRequire = shouldUseRequire(sourceFile, program);
149701
- var exportInfos = getExportInfos(symbolName, ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
149936
+ var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
149702
149937
  var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
149703
149938
  var _ = _a[0], exportInfos = _a[1];
149704
149939
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
149705
149940
  }));
149706
- return { fixes: fixes, symbolName: symbolName };
149941
+ return { fixes: fixes, symbolName: symbolName, errorIdentifierText: symbolToken.text };
149942
+ }
149943
+ function getTypeOnlyPromotionFix(sourceFile, symbolToken, symbolName, program) {
149944
+ var checker = program.getTypeChecker();
149945
+ var symbol = checker.resolveName(symbolName, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
149946
+ if (!symbol)
149947
+ return undefined;
149948
+ var typeOnlyAliasDeclaration = checker.getTypeOnlyAliasDeclaration(symbol);
149949
+ if (!typeOnlyAliasDeclaration || ts.getSourceFileOfNode(typeOnlyAliasDeclaration) !== sourceFile)
149950
+ return undefined;
149951
+ return { kind: 4 /* PromoteTypeOnly */, typeOnlyAliasDeclaration: typeOnlyAliasDeclaration };
149707
149952
  }
149708
149953
  function jsxModeNeedsExplicitImport(jsx) {
149709
149954
  return jsx === 2 /* React */ || jsx === 3 /* ReactNative */;
@@ -149712,14 +149957,20 @@ var ts;
149712
149957
  var parent = symbolToken.parent;
149713
149958
  if ((ts.isJsxOpeningLikeElement(parent) || ts.isJsxClosingElement(parent)) && parent.tagName === symbolToken && jsxModeNeedsExplicitImport(compilerOptions.jsx)) {
149714
149959
  var jsxNamespace = checker.getJsxNamespace(sourceFile);
149715
- if (ts.isIntrinsicJsxName(symbolToken.text) || !checker.resolveName(jsxNamespace, parent, 111551 /* Value */, /*excludeGlobals*/ true)) {
149960
+ if (needsJsxNamespaceFix(jsxNamespace, symbolToken, checker)) {
149716
149961
  return jsxNamespace;
149717
149962
  }
149718
149963
  }
149719
149964
  return symbolToken.text;
149720
149965
  }
149966
+ function needsJsxNamespaceFix(jsxNamespace, symbolToken, checker) {
149967
+ if (ts.isIntrinsicJsxName(symbolToken.text))
149968
+ return true; // If we were triggered by a matching error code on an intrinsic, the error must have been about missing the JSX factory
149969
+ var namespaceSymbol = checker.resolveName(jsxNamespace, symbolToken, 111551 /* Value */, /*excludeGlobals*/ true);
149970
+ return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
149971
+ }
149721
149972
  // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
149722
- function getExportInfos(symbolName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
149973
+ function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
149723
149974
  var _a;
149724
149975
  // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
149725
149976
  // Maps symbol id to info for modules providing that symbol (original export + re-exports).
@@ -149742,7 +149993,7 @@ var ts;
149742
149993
  cancellationToken.throwIfCancellationRequested();
149743
149994
  var compilerOptions = program.getCompilerOptions();
149744
149995
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
149745
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions)) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
149996
+ if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
149746
149997
  addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
149747
149998
  }
149748
149999
  // check exports with the same name
@@ -149782,14 +150033,14 @@ var ts;
149782
150033
  // allowSyntheticDefaultImports/esModuleInterop is enabled.
149783
150034
  return allowSyntheticDefaults ? 1 /* Default */ : 3 /* CommonJS */;
149784
150035
  }
149785
- function codeActionForFix(context, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150036
+ function codeActionForFix(context, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
149786
150037
  var diag;
149787
150038
  var changes = ts.textChanges.ChangeTracker.with(context, function (tracker) {
149788
- diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, quotePreference, compilerOptions);
150039
+ diag = codeActionForFixWorker(tracker, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions);
149789
150040
  });
149790
150041
  return codefix.createCodeFixAction(codefix.importFixName, changes, diag, importFixId, ts.Diagnostics.Add_all_missing_imports);
149791
150042
  }
149792
- function codeActionForFixWorker(changes, sourceFile, symbolName, fix, quotePreference, compilerOptions) {
150043
+ function codeActionForFixWorker(changes, sourceFile, symbolName, fix, includeSymbolNameInDescription, quotePreference, compilerOptions) {
149793
150044
  switch (fix.kind) {
149794
150045
  case 0 /* UseNamespace */:
149795
150046
  addNamespaceQualifier(changes, sourceFile, fix);
@@ -149801,11 +150052,9 @@ var ts;
149801
150052
  var importClauseOrBindingPattern = fix.importClauseOrBindingPattern, importKind = fix.importKind, addAsTypeOnly = fix.addAsTypeOnly, moduleSpecifier = fix.moduleSpecifier;
149802
150053
  doAddExistingFix(changes, sourceFile, importClauseOrBindingPattern, importKind === 1 /* Default */ ? { name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined, importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : ts.emptyArray, compilerOptions);
149803
150054
  var moduleSpecifierWithoutQuotes = ts.stripQuotes(moduleSpecifier);
149804
- return [
149805
- importKind === 1 /* Default */ ? ts.Diagnostics.Add_default_import_0_to_existing_import_declaration_from_1 : ts.Diagnostics.Add_0_to_existing_import_declaration_from_1,
149806
- symbolName,
149807
- moduleSpecifierWithoutQuotes
149808
- ]; // you too!
150055
+ return includeSymbolNameInDescription
150056
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifierWithoutQuotes]
150057
+ : [ts.Diagnostics.Update_import_from_0, moduleSpecifierWithoutQuotes];
149809
150058
  }
149810
150059
  case 3 /* AddNew */: {
149811
150060
  var importKind = fix.importKind, moduleSpecifier = fix.moduleSpecifier, addAsTypeOnly = fix.addAsTypeOnly, useRequire = fix.useRequire;
@@ -149814,12 +150063,84 @@ var ts;
149814
150063
  var namedImports = importKind === 0 /* Named */ ? [{ name: symbolName, addAsTypeOnly: addAsTypeOnly }] : undefined;
149815
150064
  var namespaceLikeImport = importKind === 2 /* Namespace */ || importKind === 3 /* CommonJS */ ? { importKind: importKind, name: symbolName, addAsTypeOnly: addAsTypeOnly } : undefined;
149816
150065
  ts.insertImports(changes, sourceFile, getDeclarations(moduleSpecifier, quotePreference, defaultImport, namedImports, namespaceLikeImport), /*blankLineBetween*/ true);
149817
- return [importKind === 1 /* Default */ ? ts.Diagnostics.Import_default_0_from_module_1 : ts.Diagnostics.Import_0_from_module_1, symbolName, moduleSpecifier];
150066
+ return includeSymbolNameInDescription
150067
+ ? [ts.Diagnostics.Import_0_from_1, symbolName, moduleSpecifier]
150068
+ : [ts.Diagnostics.Add_import_from_0, moduleSpecifier];
150069
+ }
150070
+ case 4 /* PromoteTypeOnly */: {
150071
+ var typeOnlyAliasDeclaration = fix.typeOnlyAliasDeclaration;
150072
+ var promotedDeclaration = promoteFromTypeOnly(changes, typeOnlyAliasDeclaration, compilerOptions, sourceFile);
150073
+ return promotedDeclaration.kind === 269 /* ImportSpecifier */
150074
+ ? [ts.Diagnostics.Remove_type_from_import_of_0_from_1, symbolName, getModuleSpecifierText(promotedDeclaration.parent.parent)]
150075
+ : [ts.Diagnostics.Remove_type_from_import_declaration_from_0, getModuleSpecifierText(promotedDeclaration)];
149818
150076
  }
149819
150077
  default:
149820
150078
  return ts.Debug.assertNever(fix, "Unexpected fix kind " + fix.kind);
149821
150079
  }
149822
150080
  }
150081
+ function getModuleSpecifierText(promotedDeclaration) {
150082
+ var _a, _b;
150083
+ return promotedDeclaration.kind === 264 /* ImportEqualsDeclaration */
150084
+ ? ((_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()
150085
+ : ts.cast(promotedDeclaration.parent.moduleSpecifier, ts.isStringLiteral).text;
150086
+ }
150087
+ function promoteFromTypeOnly(changes, aliasDeclaration, compilerOptions, sourceFile) {
150088
+ // See comment in `doAddExistingFix` on constant with the same name.
150089
+ var convertExistingToTypeOnly = compilerOptions.preserveValueImports && compilerOptions.isolatedModules;
150090
+ switch (aliasDeclaration.kind) {
150091
+ case 269 /* ImportSpecifier */:
150092
+ if (aliasDeclaration.isTypeOnly) {
150093
+ if (aliasDeclaration.parent.elements.length > 1 && ts.OrganizeImports.importSpecifiersAreSorted(aliasDeclaration.parent.elements)) {
150094
+ changes.delete(sourceFile, aliasDeclaration);
150095
+ var newSpecifier = ts.factory.updateImportSpecifier(aliasDeclaration, /*isTypeOnly*/ false, aliasDeclaration.propertyName, aliasDeclaration.name);
150096
+ var insertionIndex = ts.OrganizeImports.getImportSpecifierInsertionIndex(aliasDeclaration.parent.elements, newSpecifier);
150097
+ changes.insertImportSpecifierAtIndex(sourceFile, newSpecifier, aliasDeclaration.parent, insertionIndex);
150098
+ }
150099
+ else {
150100
+ changes.deleteRange(sourceFile, aliasDeclaration.getFirstToken());
150101
+ }
150102
+ return aliasDeclaration;
150103
+ }
150104
+ else {
150105
+ ts.Debug.assert(aliasDeclaration.parent.parent.isTypeOnly);
150106
+ promoteImportClause(aliasDeclaration.parent.parent);
150107
+ return aliasDeclaration.parent.parent;
150108
+ }
150109
+ case 266 /* ImportClause */:
150110
+ promoteImportClause(aliasDeclaration);
150111
+ return aliasDeclaration;
150112
+ case 267 /* NamespaceImport */:
150113
+ promoteImportClause(aliasDeclaration.parent);
150114
+ return aliasDeclaration.parent;
150115
+ case 264 /* ImportEqualsDeclaration */:
150116
+ changes.deleteRange(sourceFile, aliasDeclaration.getChildAt(1));
150117
+ return aliasDeclaration;
150118
+ default:
150119
+ ts.Debug.failBadSyntaxKind(aliasDeclaration);
150120
+ }
150121
+ function promoteImportClause(importClause) {
150122
+ changes.delete(sourceFile, ts.getTypeKeywordOfTypeOnlyImport(importClause, sourceFile));
150123
+ if (convertExistingToTypeOnly) {
150124
+ var namedImports = ts.tryCast(importClause.namedBindings, ts.isNamedImports);
150125
+ if (namedImports && namedImports.elements.length > 1) {
150126
+ if (ts.OrganizeImports.importSpecifiersAreSorted(namedImports.elements) &&
150127
+ aliasDeclaration.kind === 269 /* ImportSpecifier */ &&
150128
+ namedImports.elements.indexOf(aliasDeclaration) !== 0) {
150129
+ // The import specifier being promoted will be the only non-type-only,
150130
+ // import in the NamedImports, so it should be moved to the front.
150131
+ changes.delete(sourceFile, aliasDeclaration);
150132
+ changes.insertImportSpecifierAtIndex(sourceFile, aliasDeclaration, namedImports, 0);
150133
+ }
150134
+ for (var _i = 0, _a = namedImports.elements; _i < _a.length; _i++) {
150135
+ var element = _a[_i];
150136
+ if (element !== aliasDeclaration && !element.isTypeOnly) {
150137
+ changes.insertModifierBefore(sourceFile, 151 /* TypeKeyword */, element);
150138
+ }
150139
+ }
150140
+ }
150141
+ }
150142
+ }
150143
+ }
149823
150144
  function doAddExistingFix(changes, sourceFile, clause, defaultImport, namedImports, compilerOptions) {
149824
150145
  var _a;
149825
150146
  if (clause.kind === 200 /* ObjectBindingPattern */) {
@@ -149857,13 +150178,7 @@ var ts;
149857
150178
  var insertionIndex = convertExistingToTypeOnly && !spec.isTypeOnly
149858
150179
  ? 0
149859
150180
  : ts.OrganizeImports.getImportSpecifierInsertionIndex(existingSpecifiers, spec);
149860
- var prevSpecifier = clause.namedBindings.elements[insertionIndex - 1];
149861
- if (prevSpecifier) {
149862
- changes.insertNodeInListAfter(sourceFile, prevSpecifier, spec);
149863
- }
149864
- else {
149865
- changes.insertNodeBefore(sourceFile, existingSpecifiers[0], spec, !ts.positionsAreOnSameLine(existingSpecifiers[0].getStart(), clause.parent.getStart(), sourceFile));
149866
- }
150181
+ changes.insertImportSpecifierAtIndex(sourceFile, spec, clause.namedBindings, insertionIndex);
149867
150182
  }
149868
150183
  }
149869
150184
  else if (existingSpecifiers === null || existingSpecifiers === void 0 ? void 0 : existingSpecifiers.length) {
@@ -149978,17 +150293,20 @@ var ts;
149978
150293
  var declarations = _a.declarations;
149979
150294
  return ts.some(declarations, function (decl) { return !!(ts.getMeaningFromDeclaration(decl) & meaning); });
149980
150295
  }
149981
- function moduleSymbolToValidIdentifier(moduleSymbol, target) {
149982
- return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target);
150296
+ function moduleSymbolToValidIdentifier(moduleSymbol, target, forceCapitalize) {
150297
+ return moduleSpecifierToValidIdentifier(ts.removeFileExtension(ts.stripQuotes(moduleSymbol.name)), target, forceCapitalize);
149983
150298
  }
149984
150299
  codefix.moduleSymbolToValidIdentifier = moduleSymbolToValidIdentifier;
149985
- function moduleSpecifierToValidIdentifier(moduleSpecifier, target) {
150300
+ function moduleSpecifierToValidIdentifier(moduleSpecifier, target, forceCapitalize) {
149986
150301
  var baseName = ts.getBaseFileName(ts.removeSuffix(moduleSpecifier, "/index"));
149987
150302
  var res = "";
149988
150303
  var lastCharWasValid = true;
149989
150304
  var firstCharCode = baseName.charCodeAt(0);
149990
150305
  if (ts.isIdentifierStart(firstCharCode, target)) {
149991
150306
  res += String.fromCharCode(firstCharCode);
150307
+ if (forceCapitalize) {
150308
+ res = res.toUpperCase();
150309
+ }
149992
150310
  }
149993
150311
  else {
149994
150312
  lastCharWasValid = false;
@@ -159957,13 +160275,11 @@ var ts;
159957
160275
  switch (context === null || context === void 0 ? void 0 : context.kind) {
159958
160276
  case 171 /* GetAccessor */:
159959
160277
  if (!this.contextualGetAccessorDocumentationComment) {
159960
- this.contextualGetAccessorDocumentationComment = ts.emptyArray;
159961
160278
  this.contextualGetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isGetAccessor), checker);
159962
160279
  }
159963
160280
  return this.contextualGetAccessorDocumentationComment;
159964
160281
  case 172 /* SetAccessor */:
159965
160282
  if (!this.contextualSetAccessorDocumentationComment) {
159966
- this.contextualSetAccessorDocumentationComment = ts.emptyArray;
159967
160283
  this.contextualSetAccessorDocumentationComment = getDocumentationComment(ts.filter(this.declarations, ts.isSetAccessor), checker);
159968
160284
  }
159969
160285
  return this.contextualSetAccessorDocumentationComment;
@@ -159973,10 +160289,26 @@ var ts;
159973
160289
  };
159974
160290
  SymbolObject.prototype.getJsDocTags = function (checker) {
159975
160291
  if (this.tags === undefined) {
159976
- this.tags = ts.JsDoc.getJsDocTagsFromDeclarations(this.declarations, checker);
160292
+ this.tags = getJsDocTagsOfDeclarations(this.declarations, checker);
159977
160293
  }
159978
160294
  return this.tags;
159979
160295
  };
160296
+ SymbolObject.prototype.getContextualJsDocTags = function (context, checker) {
160297
+ switch (context === null || context === void 0 ? void 0 : context.kind) {
160298
+ case 171 /* GetAccessor */:
160299
+ if (!this.contextualGetAccessorTags) {
160300
+ this.contextualGetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isGetAccessor), checker);
160301
+ }
160302
+ return this.contextualGetAccessorTags;
160303
+ case 172 /* SetAccessor */:
160304
+ if (!this.contextualSetAccessorTags) {
160305
+ this.contextualSetAccessorTags = getJsDocTagsOfDeclarations(ts.filter(this.declarations, ts.isSetAccessor), checker);
160306
+ }
160307
+ return this.contextualSetAccessorTags;
160308
+ default:
160309
+ return this.getJsDocTags(checker);
160310
+ }
160311
+ };
159980
160312
  return SymbolObject;
159981
160313
  }());
159982
160314
  var TokenObject = /** @class */ (function (_super) {
@@ -160146,10 +160478,7 @@ var ts;
160146
160478
  return this.documentationComment || (this.documentationComment = getDocumentationComment(ts.singleElementArray(this.declaration), this.checker));
160147
160479
  };
160148
160480
  SignatureObject.prototype.getJsDocTags = function () {
160149
- if (this.jsDocTags === undefined) {
160150
- this.jsDocTags = this.declaration ? getJsDocTagsOfSignature(this.declaration, this.checker) : [];
160151
- }
160152
- return this.jsDocTags;
160481
+ return this.jsDocTags || (this.jsDocTags = getJsDocTagsOfDeclarations(ts.singleElementArray(this.declaration), this.checker));
160153
160482
  };
160154
160483
  return SignatureObject;
160155
160484
  }());
@@ -160161,12 +160490,30 @@ var ts;
160161
160490
  function hasJSDocInheritDocTag(node) {
160162
160491
  return ts.getJSDocTags(node).some(function (tag) { return tag.tagName.text === "inheritDoc"; });
160163
160492
  }
160164
- function getJsDocTagsOfSignature(declaration, checker) {
160165
- var tags = ts.JsDoc.getJsDocTagsFromDeclarations([declaration], checker);
160166
- if (tags.length === 0 || hasJSDocInheritDocTag(declaration)) {
160167
- var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) { var _a; return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined; });
160168
- if (inheritedTags) {
160169
- tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
160493
+ function getJsDocTagsOfDeclarations(declarations, checker) {
160494
+ if (!declarations)
160495
+ return ts.emptyArray;
160496
+ var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
160497
+ if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
160498
+ var seenSymbols_1 = new ts.Set();
160499
+ var _loop_22 = function (declaration) {
160500
+ var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
160501
+ var _a;
160502
+ if (!seenSymbols_1.has(symbol)) {
160503
+ seenSymbols_1.add(symbol);
160504
+ if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
160505
+ return symbol.getContextualJsDocTags(declaration, checker);
160506
+ }
160507
+ return ((_a = symbol.declarations) === null || _a === void 0 ? void 0 : _a.length) === 1 ? symbol.getJsDocTags() : undefined;
160508
+ }
160509
+ });
160510
+ if (inheritedTags) {
160511
+ tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
160512
+ }
160513
+ };
160514
+ for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
160515
+ var declaration = declarations_6[_i];
160516
+ _loop_22(declaration);
160170
160517
  }
160171
160518
  }
160172
160519
  return tags;
@@ -160176,18 +160523,24 @@ var ts;
160176
160523
  return ts.emptyArray;
160177
160524
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
160178
160525
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
160179
- var seenSymbols_1 = new ts.Set();
160180
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
160181
- var declaration = declarations_6[_i];
160526
+ var seenSymbols_2 = new ts.Set();
160527
+ var _loop_23 = function (declaration) {
160182
160528
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
160183
- if (!seenSymbols_1.has(symbol)) {
160184
- seenSymbols_1.add(symbol);
160529
+ if (!seenSymbols_2.has(symbol)) {
160530
+ seenSymbols_2.add(symbol);
160531
+ if (declaration.kind === 171 /* GetAccessor */ || declaration.kind === 172 /* SetAccessor */) {
160532
+ return symbol.getContextualDocumentationComment(declaration, checker);
160533
+ }
160185
160534
  return symbol.getDocumentationComment(checker);
160186
160535
  }
160187
160536
  });
160188
160537
  // TODO: GH#16312 Return a ReadonlyArray, avoid copying inheritedDocs
160189
160538
  if (inheritedDocs)
160190
160539
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
160540
+ };
160541
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
160542
+ var declaration = declarations_7[_i];
160543
+ _loop_23(declaration);
160191
160544
  }
160192
160545
  }
160193
160546
  return doc;