typescript 4.6.0-dev.20220202 → 4.6.0-dev.20220206

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.20220202";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220206";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -1274,11 +1274,11 @@ var ts;
1274
1274
  return result;
1275
1275
  }
1276
1276
  ts.getAllKeys = getAllKeys;
1277
- function getOwnValues(sparseArray) {
1277
+ function getOwnValues(collection) {
1278
1278
  var values = [];
1279
- for (var key in sparseArray) {
1280
- if (hasOwnProperty.call(sparseArray, key)) {
1281
- values.push(sparseArray[key]);
1279
+ for (var key in collection) {
1280
+ if (hasOwnProperty.call(collection, key)) {
1281
+ values.push(collection[key]);
1282
1282
  }
1283
1283
  }
1284
1284
  return values;
@@ -8681,12 +8681,10 @@ var ts;
8681
8681
  Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es2015_or_higher: diag(2802, ts.DiagnosticCategory.Error, "Type_0_can_only_be_iterated_through_when_using_the_downlevelIteration_flag_or_with_a_target_of_es201_2802", "Type '{0}' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher."),
8682
8682
  Cannot_assign_to_private_method_0_Private_methods_are_not_writable: diag(2803, ts.DiagnosticCategory.Error, "Cannot_assign_to_private_method_0_Private_methods_are_not_writable_2803", "Cannot assign to private method '{0}'. Private methods are not writable."),
8683
8683
  Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name: diag(2804, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_Static_and_instance_elements_cannot_share_the_same_private_name_2804", "Duplicate identifier '{0}'. Static and instance elements cannot share the same private name."),
8684
- Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag: diag(2805, ts.DiagnosticCategory.Error, "Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_no_2805", "Static fields with private names can't have initializers when the '--useDefineForClassFields' flag is not specified with a '--target' of 'esnext'. Consider adding the '--useDefineForClassFields' flag."),
8685
8684
  Private_accessor_was_defined_without_a_getter: diag(2806, ts.DiagnosticCategory.Error, "Private_accessor_was_defined_without_a_getter_2806", "Private accessor was defined without a getter."),
8686
8685
  This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_one_in_0_Consider_upgrading_your_version_of_0: diag(2807, ts.DiagnosticCategory.Error, "This_syntax_requires_an_imported_helper_named_1_with_2_parameters_which_is_not_compatible_with_the_o_2807", "This syntax requires an imported helper named '{1}' with {2} parameters, which is not compatible with the one in '{0}'. Consider upgrading your version of '{0}'."),
8687
8686
  A_get_accessor_must_be_at_least_as_accessible_as_the_setter: diag(2808, ts.DiagnosticCategory.Error, "A_get_accessor_must_be_at_least_as_accessible_as_the_setter_2808", "A get accessor must be at least as accessible as the setter"),
8688
8687
  Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_destructuring_assignment_you_might_need_to_wrap_the_the_whole_assignment_in_parentheses: diag(2809, ts.DiagnosticCategory.Error, "Declaration_or_statement_expected_This_follows_a_block_of_statements_so_if_you_intended_to_write_a_d_2809", "Declaration or statement expected. This '=' follows a block of statements, so if you intended to write a destructuring assignment, you might need to wrap the the whole assignment in parentheses."),
8689
- Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false: diag(2810, ts.DiagnosticCategory.Error, "Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnex_2810", "Property '{0}' may not be used in a static property's initializer in the same class when 'target' is 'esnext' and 'useDefineForClassFields' is 'false'."),
8690
8688
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8691
8689
  Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom: diag(2812, ts.DiagnosticCategory.Error, "Property_0_does_not_exist_on_type_1_Try_changing_the_lib_compiler_option_to_include_dom_2812", "Property '{0}' does not exist on type '{1}'. Try changing the 'lib' compiler option to include 'dom'."),
8692
8690
  Class_declaration_cannot_implement_overload_list_for_0: diag(2813, ts.DiagnosticCategory.Error, "Class_declaration_cannot_implement_overload_list_for_0_2813", "Class declaration cannot implement overload list for '{0}'."),
@@ -9637,6 +9635,7 @@ var ts;
9637
9635
  Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
9638
9636
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
9639
9637
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
9638
+ Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
9640
9639
  No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer: diag(18004, ts.DiagnosticCategory.Error, "No_value_exists_in_scope_for_the_shorthand_property_0_Either_declare_one_or_provide_an_initializer_18004", "No value exists in scope for the shorthand property '{0}'. Either declare one or provide an initializer."),
9641
9640
  Classes_may_not_have_a_field_named_constructor: diag(18006, ts.DiagnosticCategory.Error, "Classes_may_not_have_a_field_named_constructor_18006", "Classes may not have a field named 'constructor'."),
9642
9641
  JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array: diag(18007, ts.DiagnosticCategory.Error, "JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array_18007", "JSX expressions may not use the comma operator. Did you mean to write an array?"),
@@ -12809,12 +12808,17 @@ var ts;
12809
12808
  /** Gets the text of a jsdoc comment, flattening links to their text. */
12810
12809
  function getTextOfJSDocComment(comment) {
12811
12810
  return typeof comment === "string" ? comment
12812
- : comment === null || comment === void 0 ? void 0 : comment.map(function (c) {
12813
- // TODO: Other kinds here
12814
- return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}";
12815
- }).join("");
12811
+ : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
12816
12812
  }
12817
12813
  ts.getTextOfJSDocComment = getTextOfJSDocComment;
12814
+ function formatJSDocLink(link) {
12815
+ var kind = link.kind === 322 /* JSDocLink */ ? "link"
12816
+ : link.kind === 323 /* JSDocLinkCode */ ? "linkcode"
12817
+ : "linkplain";
12818
+ var name = link.name ? ts.entityNameToString(link.name) : "";
12819
+ var space = link.name && link.text.startsWith("://") ? "" : " ";
12820
+ return "{@" + kind + " " + name + space + link.text + "}";
12821
+ }
12818
12822
  /**
12819
12823
  * Gets the effective type parameters. If the node was parsed in a
12820
12824
  * JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
@@ -72947,23 +72951,6 @@ var ts;
72947
72951
  if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
72948
72952
  grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
72949
72953
  }
72950
- if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
72951
- var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
72952
- var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
72953
- if (n === lexicalClass_1)
72954
- return "quit";
72955
- if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
72956
- return true;
72957
- }
72958
- return false;
72959
- });
72960
- if (parentStaticFieldInitializer) {
72961
- var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
72962
- ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
72963
- var diagnostic = error(node, ts.Diagnostics.Property_0_may_not_be_used_in_a_static_property_s_initializer_in_the_same_class_when_target_is_esnext_and_useDefineForClassFields_is_false, ts.symbolName(lexicallyScopedSymbol));
72964
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
72965
- }
72966
- }
72967
72954
  if (isAnyLike) {
72968
72955
  if (lexicallyScopedSymbol) {
72969
72956
  return isErrorType(apparentType) ? errorType : apparentType;
@@ -78599,9 +78586,6 @@ var ts;
78599
78586
  checkGrammarComputedPropertyName(node.name);
78600
78587
  checkVariableLikeDeclaration(node);
78601
78588
  setNodeLinksForPrivateIdentifierScope(node);
78602
- if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
78603
- error(node.initializer, ts.Diagnostics.Static_fields_with_private_names_can_t_have_initializers_when_the_useDefineForClassFields_flag_is_not_specified_with_a_target_of_esnext_Consider_adding_the_useDefineForClassFields_flag);
78604
- }
78605
78589
  // property signatures already report "initializer not allowed in ambient context" elsewhere
78606
78590
  if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
78607
78591
  error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
@@ -92291,10 +92275,12 @@ var ts;
92291
92275
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
92292
92276
  var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
92293
92277
  var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
92278
+ // We need to transform `this` in a static initializer into a reference to the class
92279
+ // when targeting < ES2022 since the assignment will be moved outside of the class body.
92280
+ var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
92294
92281
  // We don't need to transform `super` property access when targeting ES5, ES3 because
92295
92282
  // the es2015 transformation handles those.
92296
- var shouldTransformSuperInStaticInitializers = (languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields) && languageVersion >= 2 /* ES2015 */;
92297
- var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
92283
+ var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
92298
92284
  var previousOnSubstituteNode = context.onSubstituteNode;
92299
92285
  context.onSubstituteNode = onSubstituteNode;
92300
92286
  var previousOnEmitNode = context.onEmitNode;
@@ -92523,6 +92509,10 @@ var ts;
92523
92509
  ts.Debug.assert(!ts.some(node.decorators));
92524
92510
  if (ts.isPrivateIdentifier(node.name)) {
92525
92511
  if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
92512
+ if (ts.isStatic(node)) {
92513
+ // static fields are left as is
92514
+ return ts.visitEachChild(node, visitor, context);
92515
+ }
92526
92516
  // Initializer is elided as the field is initialized in transformConstructor.
92527
92517
  return factory.updatePropertyDeclaration(node,
92528
92518
  /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
@@ -92544,6 +92534,22 @@ var ts;
92544
92534
  if (expr && !ts.isSimpleInlineableExpression(expr)) {
92545
92535
  getPendingExpressions().push(expr);
92546
92536
  }
92537
+ if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
92538
+ var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
92539
+ if (initializerStatement) {
92540
+ var staticBlock = factory.createClassStaticBlockDeclaration(
92541
+ /*decorators*/ undefined,
92542
+ /*modifiers*/ undefined, factory.createBlock([initializerStatement]));
92543
+ ts.setOriginalNode(staticBlock, node);
92544
+ ts.setCommentRange(staticBlock, node);
92545
+ // Set the comment range for the statement to an empty synthetic range
92546
+ // and drop synthetic comments from the statement to avoid printing them twice.
92547
+ ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
92548
+ ts.setSyntheticLeadingComments(initializerStatement, undefined);
92549
+ ts.setSyntheticTrailingComments(initializerStatement, undefined);
92550
+ return staticBlock;
92551
+ }
92552
+ }
92547
92553
  return undefined;
92548
92554
  }
92549
92555
  function createPrivateIdentifierAccess(info, receiver) {
@@ -92931,7 +92937,6 @@ var ts;
92931
92937
  if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
92932
92938
  enableSubstitutionForClassStaticThisOrSuperReference();
92933
92939
  }
92934
- var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92935
92940
  // If a class has private static fields, or a static field has a `this` or `super` reference,
92936
92941
  // then we need to allocate a temp variable to hold on to that reference.
92937
92942
  var pendingClassReferenceAssignment;
@@ -92959,6 +92964,7 @@ var ts;
92959
92964
  // From ES6 specification:
92960
92965
  // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
92961
92966
  // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
92967
+ var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92962
92968
  if (ts.some(staticProperties)) {
92963
92969
  addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
92964
92970
  }
@@ -92997,7 +93003,7 @@ var ts;
92997
93003
  }
92998
93004
  var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
92999
93005
  /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
93000
- var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(p.name)); });
93006
+ var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
93001
93007
  if (hasTransformableStatics || ts.some(pendingExpressions)) {
93002
93008
  if (isDecoratedClassDeclaration) {
93003
93009
  ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
@@ -93044,6 +93050,7 @@ var ts;
93044
93050
  return undefined;
93045
93051
  }
93046
93052
  function transformClassMembers(node, isDerivedClass) {
93053
+ var members = [];
93047
93054
  if (shouldTransformPrivateElementsOrClassStaticBlocks) {
93048
93055
  // Declare private names.
93049
93056
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
@@ -93056,12 +93063,20 @@ var ts;
93056
93063
  createBrandCheckWeakSetForPrivateMethods();
93057
93064
  }
93058
93065
  }
93059
- var members = [];
93060
93066
  var constructor = transformConstructor(node, isDerivedClass);
93067
+ var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
93061
93068
  if (constructor) {
93062
93069
  members.push(constructor);
93063
93070
  }
93064
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
93071
+ if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
93072
+ members.push(factory.createClassStaticBlockDeclaration(
93073
+ /*decorators*/ undefined,
93074
+ /*modifiers*/ undefined, factory.createBlock([
93075
+ factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
93076
+ ])));
93077
+ pendingExpressions = undefined;
93078
+ }
93079
+ ts.addRange(members, visitedMembers);
93065
93080
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
93066
93081
  }
93067
93082
  function createBrandCheckWeakSetForPrivateMethods() {
@@ -93204,24 +93219,34 @@ var ts;
93204
93219
  function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
93205
93220
  for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
93206
93221
  var property = properties_7[_i];
93207
- var expression = ts.isClassStaticBlockDeclaration(property) ?
93208
- transformClassStaticBlockDeclaration(property) :
93209
- transformProperty(property, receiver);
93210
- if (!expression) {
93222
+ if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
93223
+ continue;
93224
+ }
93225
+ var statement = transformPropertyOrClassStaticBlock(property, receiver);
93226
+ if (!statement) {
93211
93227
  continue;
93212
93228
  }
93213
- var statement = factory.createExpressionStatement(expression);
93214
- ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93215
- ts.setCommentRange(statement, property);
93216
- ts.setOriginalNode(statement, property);
93217
- // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93218
- // `statement` and `expression` have a copy of the synthesized comments.
93219
- // Drop the comments from expression to avoid printing them twice.
93220
- ts.setSyntheticLeadingComments(expression, undefined);
93221
- ts.setSyntheticTrailingComments(expression, undefined);
93222
93229
  statements.push(statement);
93223
93230
  }
93224
93231
  }
93232
+ function transformPropertyOrClassStaticBlock(property, receiver) {
93233
+ var expression = ts.isClassStaticBlockDeclaration(property) ?
93234
+ transformClassStaticBlockDeclaration(property) :
93235
+ transformProperty(property, receiver);
93236
+ if (!expression) {
93237
+ return undefined;
93238
+ }
93239
+ var statement = factory.createExpressionStatement(expression);
93240
+ ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93241
+ ts.setCommentRange(statement, property);
93242
+ ts.setOriginalNode(statement, property);
93243
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93244
+ // `statement` and `expression` have a copy of the synthesized comments.
93245
+ // Drop the comments from expression to avoid printing them twice.
93246
+ ts.setSyntheticLeadingComments(expression, undefined);
93247
+ ts.setSyntheticTrailingComments(expression, undefined);
93248
+ return statement;
93249
+ }
93225
93250
  /**
93226
93251
  * Generates assignment expressions for property initializers.
93227
93252
  *
@@ -125863,7 +125888,7 @@ var ts;
125863
125888
  parts.push(linkTextPart(text));
125864
125889
  }
125865
125890
  else {
125866
- parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
125891
+ parts.push(linkTextPart(name + (suffix || text.indexOf("://") === 0 ? "" : " ") + text));
125867
125892
  }
125868
125893
  }
125869
125894
  parts.push(linkPart("}"));
@@ -126684,15 +126709,35 @@ var ts;
126684
126709
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
126685
126710
  }
126686
126711
  ts.firstOrOnly = firstOrOnly;
126712
+ function getNamesForExportedSymbol(symbol, scriptTarget) {
126713
+ if (needsNameFromDeclaration(symbol)) {
126714
+ var fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
126715
+ if (fromDeclaration)
126716
+ return fromDeclaration;
126717
+ var fileNameCase = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ false);
126718
+ var capitalized = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ true);
126719
+ if (fileNameCase === capitalized)
126720
+ return fileNameCase;
126721
+ return [fileNameCase, capitalized];
126722
+ }
126723
+ return symbol.name;
126724
+ }
126725
+ ts.getNamesForExportedSymbol = getNamesForExportedSymbol;
126687
126726
  function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
126688
- if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
126727
+ if (needsNameFromDeclaration(symbol)) {
126689
126728
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
126690
- 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; })
126729
+ return getDefaultLikeExportNameFromDeclaration(symbol)
126691
126730
  || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
126692
126731
  }
126693
126732
  return symbol.name;
126694
126733
  }
126695
126734
  ts.getNameForExportedSymbol = getNameForExportedSymbol;
126735
+ function needsNameFromDeclaration(symbol) {
126736
+ return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
126737
+ }
126738
+ function getDefaultLikeExportNameFromDeclaration(symbol) {
126739
+ 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; });
126740
+ }
126696
126741
  function getSymbolParentOrFail(symbol) {
126697
126742
  var _a;
126698
126743
  return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " +
@@ -126862,9 +126907,11 @@ var ts;
126862
126907
  // 3. Otherwise, we have a default/namespace import that can be imported by any name, and
126863
126908
  // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
126864
126909
  // get a better name.
126865
- var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126910
+ var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126866
126911
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
126867
- : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
126912
+ : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
126913
+ var symbolName = typeof names === "string" ? names : names[0];
126914
+ var capitalizedSymbolName = typeof names === "string" ? undefined : names[1];
126868
126915
  var moduleName = ts.stripQuotes(moduleSymbol.name);
126869
126916
  var id = exportInfoId++;
126870
126917
  var target = ts.skipAlias(symbol, checker);
@@ -126872,10 +126919,11 @@ var ts;
126872
126919
  var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
126873
126920
  if (!storedSymbol || !storedModuleSymbol)
126874
126921
  symbols.set(id, [symbol, moduleSymbol]);
126875
- exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
126922
+ exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
126876
126923
  id: id,
126877
126924
  symbolTableKey: symbolTableKey,
126878
- symbolName: importedName,
126925
+ symbolName: symbolName,
126926
+ capitalizedSymbolName: capitalizedSymbolName,
126879
126927
  moduleName: moduleName,
126880
126928
  moduleFile: moduleFile,
126881
126929
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
@@ -126893,21 +126941,18 @@ var ts;
126893
126941
  var result = exportInfo.get(key);
126894
126942
  return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
126895
126943
  },
126896
- forEach: function (importingFile, action) {
126944
+ search: function (importingFile, preferCapitalized, matches, action) {
126897
126945
  if (importingFile !== usableByFileName)
126898
126946
  return;
126899
126947
  exportInfo.forEach(function (info, key) {
126900
126948
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
126901
- var rehydrated = info.map(rehydrateCachedInfo);
126902
- var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126903
- if (filtered.length) {
126904
- action(filtered, function (preferCapitalized) {
126905
- var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
126906
- var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126907
- return preferCapitalized
126908
- ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
126909
- : symbolName;
126910
- }, !!ambientModuleName, key);
126949
+ var name = preferCapitalized && info[0].capitalizedSymbolName || symbolName;
126950
+ if (matches(name, info[0].targetFlags)) {
126951
+ var rehydrated = info.map(rehydrateCachedInfo);
126952
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126953
+ if (filtered.length) {
126954
+ action(filtered, name, !!ambientModuleName, key);
126955
+ }
126911
126956
  }
126912
126957
  });
126913
126958
  },
@@ -131023,44 +131068,47 @@ var ts;
131023
131068
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
131024
131069
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131025
131070
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
131026
- exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
131027
- var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
131071
+ exportInfo.search(sourceFile.path,
131072
+ /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
131028
131073
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
131029
- return;
131074
+ return false;
131030
131075
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
131031
- return;
131032
- // `targetFlags` should be the same for each `info`
131033
- if (!isTypeOnlyLocation && !importCompletionNode && !(info[0].targetFlags & 111551 /* Value */))
131034
- return;
131035
- if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131036
- return;
131076
+ return false;
131077
+ if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
131078
+ return false;
131079
+ if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131080
+ return false;
131037
131081
  // Do not try to auto-import something with a lowercase first letter for a JSX tag
131038
131082
  var firstChar = symbolName.charCodeAt(0);
131039
131083
  if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
131084
+ return false;
131085
+ if (detailsEntryId)
131086
+ return true;
131087
+ return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
131088
+ }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
131089
+ if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
131090
+ return;
131091
+ }
131092
+ var defaultExportInfo = ts.find(info, isImportableExportInfo);
131093
+ if (!defaultExportInfo) {
131040
131094
  return;
131041
- var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
131042
- if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
131043
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
131044
- if (!defaultExportInfo) {
131045
- return;
131046
- }
131047
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131048
- // (We need to ensure that at least one is importable to show a completion.)
131049
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131050
- var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */;
131051
- var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol;
131052
- pushAutoImportSymbol(symbol, {
131053
- kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131054
- moduleSpecifier: moduleSpecifier,
131055
- symbolName: symbolName,
131056
- exportMapKey: exportMapKey,
131057
- exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
131058
- fileName: exportInfo_1.moduleFileName,
131059
- isDefaultExport: isDefaultExport,
131060
- moduleSymbol: exportInfo_1.moduleSymbol,
131061
- isFromPackageJson: exportInfo_1.isFromPackageJson,
131062
- });
131063
131095
  }
131096
+ // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131097
+ // (We need to ensure that at least one is importable to show a completion.)
131098
+ var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131099
+ var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
131100
+ var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
131101
+ pushAutoImportSymbol(symbol, {
131102
+ kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131103
+ moduleSpecifier: moduleSpecifier,
131104
+ symbolName: symbolName,
131105
+ exportMapKey: exportMapKey,
131106
+ exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
131107
+ fileName: exportInfo.moduleFileName,
131108
+ isDefaultExport: isDefaultExport,
131109
+ moduleSymbol: exportInfo.moduleSymbol,
131110
+ isFromPackageJson: exportInfo.isFromPackageJson,
131111
+ });
131064
131112
  });
131065
131113
  hasUnresolvedAutoImports = context.resolutionLimitExceeded();
131066
131114
  });
@@ -136999,7 +137047,27 @@ var ts;
136999
137047
  case 326 /* JSDocAugmentsTag */:
137000
137048
  return withNode(tag.class);
137001
137049
  case 342 /* JSDocTemplateTag */:
137002
- return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", "));
137050
+ var templateTag = tag;
137051
+ var displayParts_3 = [];
137052
+ if (templateTag.constraint) {
137053
+ displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
137054
+ }
137055
+ if (ts.length(templateTag.typeParameters)) {
137056
+ if (ts.length(displayParts_3)) {
137057
+ displayParts_3.push(ts.spacePart());
137058
+ }
137059
+ var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
137060
+ ts.forEach(templateTag.typeParameters, function (tp) {
137061
+ displayParts_3.push(namePart(tp.getText()));
137062
+ if (lastTypeParameter_1 !== tp) {
137063
+ displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
137064
+ }
137065
+ });
137066
+ }
137067
+ if (comment) {
137068
+ displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
137069
+ }
137070
+ return displayParts_3;
137003
137071
  case 341 /* JSDocTypeTag */:
137004
137072
  return withNode(tag.typeExpression);
137005
137073
  case 343 /* JSDocTypedefTag */:
@@ -138487,7 +138555,7 @@ var ts;
138487
138555
  newImportSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, ts.factory.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
138488
138556
  }
138489
138557
  }
138490
- newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
138558
+ newImportSpecifiers.push.apply(newImportSpecifiers, getNewImportSpecifiers(namedImports));
138491
138559
  var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
138492
138560
  var importDecl = defaultImports.length > 0
138493
138561
  ? defaultImports[0]
@@ -138697,6 +138765,21 @@ var ts;
138697
138765
  return 6;
138698
138766
  }
138699
138767
  }
138768
+ function getNewImportSpecifiers(namedImports) {
138769
+ return ts.flatMap(namedImports, function (namedImport) {
138770
+ return ts.map(tryGetNamedBindingElements(namedImport), function (importSpecifier) {
138771
+ return importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText
138772
+ ? ts.factory.updateImportSpecifier(importSpecifier, importSpecifier.isTypeOnly, /*propertyName*/ undefined, importSpecifier.name)
138773
+ : importSpecifier;
138774
+ });
138775
+ });
138776
+ }
138777
+ function tryGetNamedBindingElements(namedImport) {
138778
+ var _a;
138779
+ return ((_a = namedImport.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings) && ts.isNamedImports(namedImport.importClause.namedBindings)
138780
+ ? namedImport.importClause.namedBindings.elements
138781
+ : undefined;
138782
+ }
138700
138783
  })(OrganizeImports = ts.OrganizeImports || (ts.OrganizeImports = {}));
138701
138784
  })(ts || (ts = {}));
138702
138785
  /* @internal */
@@ -140410,12 +140493,12 @@ var ts;
140410
140493
  : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
140411
140494
  }
140412
140495
  SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
140413
- function getArgumentOrParameterListInfo(node, sourceFile) {
140496
+ function getArgumentOrParameterListInfo(node, position, sourceFile) {
140414
140497
  var info = getArgumentOrParameterListAndIndex(node, sourceFile);
140415
140498
  if (!info)
140416
140499
  return undefined;
140417
140500
  var list = info.list, argumentIndex = info.argumentIndex;
140418
- var argumentCount = getArgumentCount(list);
140501
+ var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
140419
140502
  if (argumentIndex !== 0) {
140420
140503
  ts.Debug.assertLessThan(argumentIndex, argumentCount);
140421
140504
  }
@@ -140461,7 +140544,7 @@ var ts;
140461
140544
  // Case 3:
140462
140545
  // foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
140463
140546
  // Find out if 'node' is an argument, a type argument, or neither
140464
- var info = getArgumentOrParameterListInfo(node, sourceFile);
140547
+ var info = getArgumentOrParameterListInfo(node, position, sourceFile);
140465
140548
  if (!info)
140466
140549
  return undefined;
140467
140550
  var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140530,8 +140613,8 @@ var ts;
140530
140613
  function countBinaryExpressionParameters(b) {
140531
140614
  return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
140532
140615
  }
140533
- function tryGetParameterInfo(startingToken, _position, sourceFile, checker) {
140534
- var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
140616
+ function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
140617
+ var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
140535
140618
  if (!info)
140536
140619
  return undefined;
140537
140620
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140543,7 +140626,7 @@ var ts;
140543
140626
  var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
140544
140627
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
140545
140628
  }
140546
- function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
140629
+ function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
140547
140630
  if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
140548
140631
  return undefined;
140549
140632
  var parent = startingToken.parent;
@@ -140552,7 +140635,7 @@ var ts;
140552
140635
  case 168 /* MethodDeclaration */:
140553
140636
  case 212 /* FunctionExpression */:
140554
140637
  case 213 /* ArrowFunction */:
140555
- var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
140638
+ var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
140556
140639
  if (!info)
140557
140640
  return undefined;
140558
140641
  var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140599,7 +140682,7 @@ var ts;
140599
140682
  }
140600
140683
  return argumentIndex;
140601
140684
  }
140602
- function getArgumentCount(argumentsList) {
140685
+ function getArgumentCount(argumentsList, ignoreTrailingComma) {
140603
140686
  // The argument count for a list is normally the number of non-comma children it has.
140604
140687
  // For example, if you have "Foo(a,b)" then there will be three children of the arg
140605
140688
  // list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
@@ -140613,7 +140696,7 @@ var ts;
140613
140696
  // arg count of 3.
140614
140697
  var listChildren = argumentsList.getChildren();
140615
140698
  var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
140616
- if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
140699
+ if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
140617
140700
  argumentCount++;
140618
140701
  }
140619
140702
  return argumentCount;
@@ -142067,6 +142150,18 @@ var ts;
142067
142150
  }
142068
142151
  }
142069
142152
  }
142153
+ if (documentation.length === 0 && ts.isIdentifier(location) && symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration)) {
142154
+ var declaration = symbol.valueDeclaration;
142155
+ var parent = declaration.parent;
142156
+ if (ts.isIdentifier(declaration.name) && ts.isObjectBindingPattern(parent)) {
142157
+ var name_4 = ts.getTextOfIdentifierOrLiteral(declaration.name);
142158
+ var objectType = typeChecker.getTypeAtLocation(parent);
142159
+ documentation = ts.firstDefined(objectType.isUnion() ? objectType.types : [objectType], function (t) {
142160
+ var prop = t.getProperty(name_4);
142161
+ return prop ? prop.getDocumentationComment(typeChecker) : undefined;
142162
+ }) || ts.emptyArray;
142163
+ }
142164
+ }
142070
142165
  if (tags.length === 0 && !hasMultipleSignatures) {
142071
142166
  tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
142072
142167
  }
@@ -155600,51 +155695,53 @@ var ts;
155600
155695
  (function (ts) {
155601
155696
  var refactor;
155602
155697
  (function (refactor) {
155698
+ var _a;
155603
155699
  var refactorName = "Convert import";
155604
- var namespaceToNamedAction = {
155605
- name: "Convert namespace import to named imports",
155606
- description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
155607
- kind: "refactor.rewrite.import.named",
155608
- };
155609
- var namedToNamespaceAction = {
155610
- name: "Convert named imports to namespace import",
155611
- description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
155612
- kind: "refactor.rewrite.import.namespace",
155613
- };
155700
+ var actions = (_a = {},
155701
+ _a[0 /* Named */] = {
155702
+ name: "Convert namespace import to named imports",
155703
+ description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
155704
+ kind: "refactor.rewrite.import.named",
155705
+ },
155706
+ _a[2 /* Namespace */] = {
155707
+ name: "Convert named imports to namespace import",
155708
+ description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
155709
+ kind: "refactor.rewrite.import.namespace",
155710
+ },
155711
+ _a[1 /* Default */] = {
155712
+ name: "Convert named imports to default import",
155713
+ description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
155714
+ kind: "refactor.rewrite.import.default",
155715
+ },
155716
+ _a);
155614
155717
  refactor.registerRefactor(refactorName, {
155615
- kinds: [
155616
- namespaceToNamedAction.kind,
155617
- namedToNamespaceAction.kind
155618
- ],
155718
+ kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
155619
155719
  getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
155620
- var info = getImportToConvert(context, context.triggerReason === "invoked");
155720
+ var info = getImportConversionInfo(context, context.triggerReason === "invoked");
155621
155721
  if (!info)
155622
155722
  return ts.emptyArray;
155623
155723
  if (!refactor.isRefactorErrorInfo(info)) {
155624
- var namespaceImport = info.kind === 267 /* NamespaceImport */;
155625
- var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
155724
+ var action = actions[info.convertTo];
155626
155725
  return [{ name: refactorName, description: action.description, actions: [action] }];
155627
155726
  }
155628
155727
  if (context.preferences.provideRefactorNotApplicableReason) {
155629
- return [
155630
- { name: refactorName, description: namespaceToNamedAction.description,
155631
- actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] },
155632
- { name: refactorName, description: namedToNamespaceAction.description,
155633
- actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] }
155634
- ];
155728
+ return ts.getOwnValues(actions).map(function (action) { return ({
155729
+ name: refactorName,
155730
+ description: action.description,
155731
+ actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
155732
+ }); });
155635
155733
  }
155636
155734
  return ts.emptyArray;
155637
155735
  },
155638
155736
  getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
155639
- ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
155640
- var info = getImportToConvert(context);
155737
+ ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
155738
+ var info = getImportConversionInfo(context);
155641
155739
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
155642
155740
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
155643
155741
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
155644
155742
  }
155645
155743
  });
155646
- // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`.
155647
- function getImportToConvert(context, considerPartialSpans) {
155744
+ function getImportConversionInfo(context, considerPartialSpans) {
155648
155745
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
155649
155746
  var file = context.file;
155650
155747
  var span = ts.getRefactorContextSpan(context);
@@ -155663,15 +155760,23 @@ var ts;
155663
155760
  if (!importClause.namedBindings) {
155664
155761
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
155665
155762
  }
155666
- return importClause.namedBindings;
155763
+ if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
155764
+ return { convertTo: 0 /* Named */, import: importClause.namedBindings };
155765
+ }
155766
+ var compilerOptions = context.program.getCompilerOptions();
155767
+ var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
155768
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
155769
+ return shouldUseDefault
155770
+ ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
155771
+ : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
155667
155772
  }
155668
- function doChange(sourceFile, program, changes, toConvert) {
155773
+ function doChange(sourceFile, program, changes, info) {
155669
155774
  var checker = program.getTypeChecker();
155670
- if (toConvert.kind === 267 /* NamespaceImport */) {
155671
- doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
155775
+ if (info.convertTo === 0 /* Named */) {
155776
+ doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
155672
155777
  }
155673
155778
  else {
155674
- doChangeNamedToNamespace(sourceFile, checker, changes, toConvert);
155779
+ doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
155675
155780
  }
155676
155781
  }
155677
155782
  function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -155721,7 +155826,7 @@ var ts;
155721
155826
  function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
155722
155827
  return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
155723
155828
  }
155724
- function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) {
155829
+ function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
155725
155830
  var importDecl = toConvert.parent.parent;
155726
155831
  var moduleSpecifier = importDecl.moduleSpecifier;
155727
155832
  var toConvertSymbols = new ts.Set();
@@ -155772,7 +155877,9 @@ var ts;
155772
155877
  var element = _a[_i];
155773
155878
  _loop_17(element);
155774
155879
  }
155775
- changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
155880
+ changes.replaceNode(sourceFile, toConvert, shouldUseDefault
155881
+ ? ts.factory.createIdentifier(namespaceImportName)
155882
+ : ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
155776
155883
  if (neededNamedImports.size) {
155777
155884
  var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
155778
155885
  return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
@@ -155780,6 +155887,13 @@ var ts;
155780
155887
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
155781
155888
  }
155782
155889
  }
155890
+ function isExportEqualsModule(moduleSpecifier, checker) {
155891
+ var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
155892
+ if (!externalModule)
155893
+ return false;
155894
+ var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
155895
+ return externalModule !== exportEquals;
155896
+ }
155783
155897
  function updateImport(old, defaultImportName, elements) {
155784
155898
  return ts.factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, ts.factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? ts.factory.createNamedImports(elements) : undefined), old.moduleSpecifier, /*assertClause*/ undefined);
155785
155899
  }
@@ -159059,7 +159173,7 @@ var ts;
159059
159173
  var convertParamsToDestructuredObject;
159060
159174
  (function (convertParamsToDestructuredObject) {
159061
159175
  var refactorName = "Convert parameters to destructured object";
159062
- var minimumParameterLength = 2;
159176
+ var minimumParameterLength = 1;
159063
159177
  var refactorDescription = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object);
159064
159178
  var toDestructuredAction = {
159065
159179
  name: refactorName,