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/typescript.js CHANGED
@@ -294,7 +294,7 @@ var ts;
294
294
  // The following is baselined as a literal template type without intervention
295
295
  /** The version of the TypeScript compiler release */
296
296
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220202";
297
+ ts.version = ts.versionMajorMinor + ".0-dev.20220206";
298
298
  /* @internal */
299
299
  var Comparison;
300
300
  (function (Comparison) {
@@ -1468,11 +1468,11 @@ var ts;
1468
1468
  return result;
1469
1469
  }
1470
1470
  ts.getAllKeys = getAllKeys;
1471
- function getOwnValues(sparseArray) {
1471
+ function getOwnValues(collection) {
1472
1472
  var values = [];
1473
- for (var key in sparseArray) {
1474
- if (hasOwnProperty.call(sparseArray, key)) {
1475
- values.push(sparseArray[key]);
1473
+ for (var key in collection) {
1474
+ if (hasOwnProperty.call(collection, key)) {
1475
+ values.push(collection[key]);
1476
1476
  }
1477
1477
  }
1478
1478
  return values;
@@ -8875,12 +8875,10 @@ var ts;
8875
8875
  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."),
8876
8876
  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."),
8877
8877
  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."),
8878
- 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."),
8879
8878
  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."),
8880
8879
  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}'."),
8881
8880
  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"),
8882
8881
  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."),
8883
- 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'."),
8884
8882
  Initializer_for_property_0: diag(2811, ts.DiagnosticCategory.Error, "Initializer_for_property_0_2811", "Initializer for property '{0}'"),
8885
8883
  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'."),
8886
8884
  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}'."),
@@ -9831,6 +9829,7 @@ var ts;
9831
9829
  Add_missing_attributes: diag(95167, ts.DiagnosticCategory.Message, "Add_missing_attributes_95167", "Add missing attributes"),
9832
9830
  Add_all_missing_attributes: diag(95168, ts.DiagnosticCategory.Message, "Add_all_missing_attributes_95168", "Add all missing attributes"),
9833
9831
  Add_undefined_to_optional_property_type: diag(95169, ts.DiagnosticCategory.Message, "Add_undefined_to_optional_property_type_95169", "Add 'undefined' to optional property type"),
9832
+ Convert_named_imports_to_default_import: diag(95170, ts.DiagnosticCategory.Message, "Convert_named_imports_to_default_import_95170", "Convert named imports to default import"),
9834
9833
  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."),
9835
9834
  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'."),
9836
9835
  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?"),
@@ -13003,12 +13002,17 @@ var ts;
13003
13002
  /** Gets the text of a jsdoc comment, flattening links to their text. */
13004
13003
  function getTextOfJSDocComment(comment) {
13005
13004
  return typeof comment === "string" ? comment
13006
- : comment === null || comment === void 0 ? void 0 : comment.map(function (c) {
13007
- // TODO: Other kinds here
13008
- return c.kind === 319 /* JSDocText */ ? c.text : "{@link " + (c.name ? ts.entityNameToString(c.name) + " " : "") + c.text + "}";
13009
- }).join("");
13005
+ : comment === null || comment === void 0 ? void 0 : comment.map(function (c) { return c.kind === 319 /* JSDocText */ ? c.text : formatJSDocLink(c); }).join("");
13010
13006
  }
13011
13007
  ts.getTextOfJSDocComment = getTextOfJSDocComment;
13008
+ function formatJSDocLink(link) {
13009
+ var kind = link.kind === 322 /* JSDocLink */ ? "link"
13010
+ : link.kind === 323 /* JSDocLinkCode */ ? "linkcode"
13011
+ : "linkplain";
13012
+ var name = link.name ? ts.entityNameToString(link.name) : "";
13013
+ var space = link.name && link.text.startsWith("://") ? "" : " ";
13014
+ return "{@" + kind + " " + name + space + link.text + "}";
13015
+ }
13012
13016
  /**
13013
13017
  * Gets the effective type parameters. If the node was parsed in a
13014
13018
  * JavaScript file, gets the type parameters from the `@template` tag from JSDoc.
@@ -73141,23 +73145,6 @@ var ts;
73141
73145
  if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
73142
73146
  grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
73143
73147
  }
73144
- if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
73145
- var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
73146
- var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
73147
- if (n === lexicalClass_1)
73148
- return "quit";
73149
- if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
73150
- return true;
73151
- }
73152
- return false;
73153
- });
73154
- if (parentStaticFieldInitializer) {
73155
- var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
73156
- ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
73157
- 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));
73158
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
73159
- }
73160
- }
73161
73148
  if (isAnyLike) {
73162
73149
  if (lexicallyScopedSymbol) {
73163
73150
  return isErrorType(apparentType) ? errorType : apparentType;
@@ -78793,9 +78780,6 @@ var ts;
78793
78780
  checkGrammarComputedPropertyName(node.name);
78794
78781
  checkVariableLikeDeclaration(node);
78795
78782
  setNodeLinksForPrivateIdentifierScope(node);
78796
- if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
78797
- 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);
78798
- }
78799
78783
  // property signatures already report "initializer not allowed in ambient context" elsewhere
78800
78784
  if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
78801
78785
  error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
@@ -92485,10 +92469,12 @@ var ts;
92485
92469
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
92486
92470
  var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
92487
92471
  var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
92472
+ // We need to transform `this` in a static initializer into a reference to the class
92473
+ // when targeting < ES2022 since the assignment will be moved outside of the class body.
92474
+ var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
92488
92475
  // We don't need to transform `super` property access when targeting ES5, ES3 because
92489
92476
  // the es2015 transformation handles those.
92490
- var shouldTransformSuperInStaticInitializers = (languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields) && languageVersion >= 2 /* ES2015 */;
92491
- var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
92477
+ var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
92492
92478
  var previousOnSubstituteNode = context.onSubstituteNode;
92493
92479
  context.onSubstituteNode = onSubstituteNode;
92494
92480
  var previousOnEmitNode = context.onEmitNode;
@@ -92717,6 +92703,10 @@ var ts;
92717
92703
  ts.Debug.assert(!ts.some(node.decorators));
92718
92704
  if (ts.isPrivateIdentifier(node.name)) {
92719
92705
  if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
92706
+ if (ts.isStatic(node)) {
92707
+ // static fields are left as is
92708
+ return ts.visitEachChild(node, visitor, context);
92709
+ }
92720
92710
  // Initializer is elided as the field is initialized in transformConstructor.
92721
92711
  return factory.updatePropertyDeclaration(node,
92722
92712
  /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
@@ -92738,6 +92728,22 @@ var ts;
92738
92728
  if (expr && !ts.isSimpleInlineableExpression(expr)) {
92739
92729
  getPendingExpressions().push(expr);
92740
92730
  }
92731
+ if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
92732
+ var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
92733
+ if (initializerStatement) {
92734
+ var staticBlock = factory.createClassStaticBlockDeclaration(
92735
+ /*decorators*/ undefined,
92736
+ /*modifiers*/ undefined, factory.createBlock([initializerStatement]));
92737
+ ts.setOriginalNode(staticBlock, node);
92738
+ ts.setCommentRange(staticBlock, node);
92739
+ // Set the comment range for the statement to an empty synthetic range
92740
+ // and drop synthetic comments from the statement to avoid printing them twice.
92741
+ ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
92742
+ ts.setSyntheticLeadingComments(initializerStatement, undefined);
92743
+ ts.setSyntheticTrailingComments(initializerStatement, undefined);
92744
+ return staticBlock;
92745
+ }
92746
+ }
92741
92747
  return undefined;
92742
92748
  }
92743
92749
  function createPrivateIdentifierAccess(info, receiver) {
@@ -93125,7 +93131,6 @@ var ts;
93125
93131
  if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
93126
93132
  enableSubstitutionForClassStaticThisOrSuperReference();
93127
93133
  }
93128
- var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
93129
93134
  // If a class has private static fields, or a static field has a `this` or `super` reference,
93130
93135
  // then we need to allocate a temp variable to hold on to that reference.
93131
93136
  var pendingClassReferenceAssignment;
@@ -93153,6 +93158,7 @@ var ts;
93153
93158
  // From ES6 specification:
93154
93159
  // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
93155
93160
  // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
93161
+ var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
93156
93162
  if (ts.some(staticProperties)) {
93157
93163
  addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
93158
93164
  }
@@ -93191,7 +93197,7 @@ var ts;
93191
93197
  }
93192
93198
  var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
93193
93199
  /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
93194
- var hasTransformableStatics = ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || (shouldTransformPrivateElementsOrClassStaticBlocks && ts.isPrivateIdentifier(p.name)); });
93200
+ var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
93195
93201
  if (hasTransformableStatics || ts.some(pendingExpressions)) {
93196
93202
  if (isDecoratedClassDeclaration) {
93197
93203
  ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
@@ -93238,6 +93244,7 @@ var ts;
93238
93244
  return undefined;
93239
93245
  }
93240
93246
  function transformClassMembers(node, isDerivedClass) {
93247
+ var members = [];
93241
93248
  if (shouldTransformPrivateElementsOrClassStaticBlocks) {
93242
93249
  // Declare private names.
93243
93250
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
@@ -93250,12 +93257,20 @@ var ts;
93250
93257
  createBrandCheckWeakSetForPrivateMethods();
93251
93258
  }
93252
93259
  }
93253
- var members = [];
93254
93260
  var constructor = transformConstructor(node, isDerivedClass);
93261
+ var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
93255
93262
  if (constructor) {
93256
93263
  members.push(constructor);
93257
93264
  }
93258
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
93265
+ if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
93266
+ members.push(factory.createClassStaticBlockDeclaration(
93267
+ /*decorators*/ undefined,
93268
+ /*modifiers*/ undefined, factory.createBlock([
93269
+ factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
93270
+ ])));
93271
+ pendingExpressions = undefined;
93272
+ }
93273
+ ts.addRange(members, visitedMembers);
93259
93274
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
93260
93275
  }
93261
93276
  function createBrandCheckWeakSetForPrivateMethods() {
@@ -93398,24 +93413,34 @@ var ts;
93398
93413
  function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
93399
93414
  for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
93400
93415
  var property = properties_7[_i];
93401
- var expression = ts.isClassStaticBlockDeclaration(property) ?
93402
- transformClassStaticBlockDeclaration(property) :
93403
- transformProperty(property, receiver);
93404
- if (!expression) {
93416
+ if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
93417
+ continue;
93418
+ }
93419
+ var statement = transformPropertyOrClassStaticBlock(property, receiver);
93420
+ if (!statement) {
93405
93421
  continue;
93406
93422
  }
93407
- var statement = factory.createExpressionStatement(expression);
93408
- ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93409
- ts.setCommentRange(statement, property);
93410
- ts.setOriginalNode(statement, property);
93411
- // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93412
- // `statement` and `expression` have a copy of the synthesized comments.
93413
- // Drop the comments from expression to avoid printing them twice.
93414
- ts.setSyntheticLeadingComments(expression, undefined);
93415
- ts.setSyntheticTrailingComments(expression, undefined);
93416
93423
  statements.push(statement);
93417
93424
  }
93418
93425
  }
93426
+ function transformPropertyOrClassStaticBlock(property, receiver) {
93427
+ var expression = ts.isClassStaticBlockDeclaration(property) ?
93428
+ transformClassStaticBlockDeclaration(property) :
93429
+ transformProperty(property, receiver);
93430
+ if (!expression) {
93431
+ return undefined;
93432
+ }
93433
+ var statement = factory.createExpressionStatement(expression);
93434
+ ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93435
+ ts.setCommentRange(statement, property);
93436
+ ts.setOriginalNode(statement, property);
93437
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93438
+ // `statement` and `expression` have a copy of the synthesized comments.
93439
+ // Drop the comments from expression to avoid printing them twice.
93440
+ ts.setSyntheticLeadingComments(expression, undefined);
93441
+ ts.setSyntheticTrailingComments(expression, undefined);
93442
+ return statement;
93443
+ }
93419
93444
  /**
93420
93445
  * Generates assignment expressions for property initializers.
93421
93446
  *
@@ -126474,7 +126499,7 @@ var ts;
126474
126499
  parts.push(linkTextPart(text));
126475
126500
  }
126476
126501
  else {
126477
- parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
126502
+ parts.push(linkTextPart(name + (suffix || text.indexOf("://") === 0 ? "" : " ") + text));
126478
126503
  }
126479
126504
  }
126480
126505
  parts.push(linkPart("}"));
@@ -127295,15 +127320,35 @@ var ts;
127295
127320
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
127296
127321
  }
127297
127322
  ts.firstOrOnly = firstOrOnly;
127323
+ function getNamesForExportedSymbol(symbol, scriptTarget) {
127324
+ if (needsNameFromDeclaration(symbol)) {
127325
+ var fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
127326
+ if (fromDeclaration)
127327
+ return fromDeclaration;
127328
+ var fileNameCase = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ false);
127329
+ var capitalized = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ true);
127330
+ if (fileNameCase === capitalized)
127331
+ return fileNameCase;
127332
+ return [fileNameCase, capitalized];
127333
+ }
127334
+ return symbol.name;
127335
+ }
127336
+ ts.getNamesForExportedSymbol = getNamesForExportedSymbol;
127298
127337
  function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
127299
- if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
127338
+ if (needsNameFromDeclaration(symbol)) {
127300
127339
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
127301
- 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; })
127340
+ return getDefaultLikeExportNameFromDeclaration(symbol)
127302
127341
  || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
127303
127342
  }
127304
127343
  return symbol.name;
127305
127344
  }
127306
127345
  ts.getNameForExportedSymbol = getNameForExportedSymbol;
127346
+ function needsNameFromDeclaration(symbol) {
127347
+ return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
127348
+ }
127349
+ function getDefaultLikeExportNameFromDeclaration(symbol) {
127350
+ 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; });
127351
+ }
127307
127352
  function getSymbolParentOrFail(symbol) {
127308
127353
  var _a;
127309
127354
  return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " +
@@ -127473,9 +127518,11 @@ var ts;
127473
127518
  // 3. Otherwise, we have a default/namespace import that can be imported by any name, and
127474
127519
  // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
127475
127520
  // get a better name.
127476
- var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
127521
+ var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
127477
127522
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
127478
- : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
127523
+ : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
127524
+ var symbolName = typeof names === "string" ? names : names[0];
127525
+ var capitalizedSymbolName = typeof names === "string" ? undefined : names[1];
127479
127526
  var moduleName = ts.stripQuotes(moduleSymbol.name);
127480
127527
  var id = exportInfoId++;
127481
127528
  var target = ts.skipAlias(symbol, checker);
@@ -127483,10 +127530,11 @@ var ts;
127483
127530
  var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
127484
127531
  if (!storedSymbol || !storedModuleSymbol)
127485
127532
  symbols.set(id, [symbol, moduleSymbol]);
127486
- exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
127533
+ exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
127487
127534
  id: id,
127488
127535
  symbolTableKey: symbolTableKey,
127489
- symbolName: importedName,
127536
+ symbolName: symbolName,
127537
+ capitalizedSymbolName: capitalizedSymbolName,
127490
127538
  moduleName: moduleName,
127491
127539
  moduleFile: moduleFile,
127492
127540
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
@@ -127504,21 +127552,18 @@ var ts;
127504
127552
  var result = exportInfo.get(key);
127505
127553
  return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
127506
127554
  },
127507
- forEach: function (importingFile, action) {
127555
+ search: function (importingFile, preferCapitalized, matches, action) {
127508
127556
  if (importingFile !== usableByFileName)
127509
127557
  return;
127510
127558
  exportInfo.forEach(function (info, key) {
127511
127559
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
127512
- var rehydrated = info.map(rehydrateCachedInfo);
127513
- var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
127514
- if (filtered.length) {
127515
- action(filtered, function (preferCapitalized) {
127516
- var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
127517
- var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
127518
- return preferCapitalized
127519
- ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
127520
- : symbolName;
127521
- }, !!ambientModuleName, key);
127560
+ var name = preferCapitalized && info[0].capitalizedSymbolName || symbolName;
127561
+ if (matches(name, info[0].targetFlags)) {
127562
+ var rehydrated = info.map(rehydrateCachedInfo);
127563
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
127564
+ if (filtered.length) {
127565
+ action(filtered, name, !!ambientModuleName, key);
127566
+ }
127522
127567
  }
127523
127568
  });
127524
127569
  },
@@ -131634,44 +131679,47 @@ var ts;
131634
131679
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
131635
131680
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131636
131681
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
131637
- exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
131638
- var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
131682
+ exportInfo.search(sourceFile.path,
131683
+ /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
131639
131684
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
131640
- return;
131685
+ return false;
131641
131686
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
131642
- return;
131643
- // `targetFlags` should be the same for each `info`
131644
- if (!isTypeOnlyLocation && !importCompletionNode && !(info[0].targetFlags & 111551 /* Value */))
131645
- return;
131646
- if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131647
- return;
131687
+ return false;
131688
+ if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
131689
+ return false;
131690
+ if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131691
+ return false;
131648
131692
  // Do not try to auto-import something with a lowercase first letter for a JSX tag
131649
131693
  var firstChar = symbolName.charCodeAt(0);
131650
131694
  if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
131695
+ return false;
131696
+ if (detailsEntryId)
131697
+ return true;
131698
+ return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
131699
+ }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
131700
+ if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
131701
+ return;
131702
+ }
131703
+ var defaultExportInfo = ts.find(info, isImportableExportInfo);
131704
+ if (!defaultExportInfo) {
131651
131705
  return;
131652
- var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
131653
- if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
131654
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
131655
- if (!defaultExportInfo) {
131656
- return;
131657
- }
131658
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131659
- // (We need to ensure that at least one is importable to show a completion.)
131660
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131661
- var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */;
131662
- var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol;
131663
- pushAutoImportSymbol(symbol, {
131664
- kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131665
- moduleSpecifier: moduleSpecifier,
131666
- symbolName: symbolName,
131667
- exportMapKey: exportMapKey,
131668
- exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
131669
- fileName: exportInfo_1.moduleFileName,
131670
- isDefaultExport: isDefaultExport,
131671
- moduleSymbol: exportInfo_1.moduleSymbol,
131672
- isFromPackageJson: exportInfo_1.isFromPackageJson,
131673
- });
131674
131706
  }
131707
+ // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131708
+ // (We need to ensure that at least one is importable to show a completion.)
131709
+ var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131710
+ var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
131711
+ var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
131712
+ pushAutoImportSymbol(symbol, {
131713
+ kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131714
+ moduleSpecifier: moduleSpecifier,
131715
+ symbolName: symbolName,
131716
+ exportMapKey: exportMapKey,
131717
+ exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
131718
+ fileName: exportInfo.moduleFileName,
131719
+ isDefaultExport: isDefaultExport,
131720
+ moduleSymbol: exportInfo.moduleSymbol,
131721
+ isFromPackageJson: exportInfo.isFromPackageJson,
131722
+ });
131675
131723
  });
131676
131724
  hasUnresolvedAutoImports = context.resolutionLimitExceeded();
131677
131725
  });
@@ -137610,7 +137658,27 @@ var ts;
137610
137658
  case 326 /* JSDocAugmentsTag */:
137611
137659
  return withNode(tag.class);
137612
137660
  case 342 /* JSDocTemplateTag */:
137613
- return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", "));
137661
+ var templateTag = tag;
137662
+ var displayParts_3 = [];
137663
+ if (templateTag.constraint) {
137664
+ displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
137665
+ }
137666
+ if (ts.length(templateTag.typeParameters)) {
137667
+ if (ts.length(displayParts_3)) {
137668
+ displayParts_3.push(ts.spacePart());
137669
+ }
137670
+ var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
137671
+ ts.forEach(templateTag.typeParameters, function (tp) {
137672
+ displayParts_3.push(namePart(tp.getText()));
137673
+ if (lastTypeParameter_1 !== tp) {
137674
+ displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
137675
+ }
137676
+ });
137677
+ }
137678
+ if (comment) {
137679
+ displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
137680
+ }
137681
+ return displayParts_3;
137614
137682
  case 341 /* JSDocTypeTag */:
137615
137683
  return withNode(tag.typeExpression);
137616
137684
  case 343 /* JSDocTypedefTag */:
@@ -139098,7 +139166,7 @@ var ts;
139098
139166
  newImportSpecifiers.push(ts.factory.createImportSpecifier(/*isTypeOnly*/ false, ts.factory.createIdentifier("default"), defaultImport.importClause.name)); // TODO: GH#18217
139099
139167
  }
139100
139168
  }
139101
- newImportSpecifiers.push.apply(newImportSpecifiers, ts.flatMap(namedImports, function (i) { return i.importClause.namedBindings.elements; })); // TODO: GH#18217
139169
+ newImportSpecifiers.push.apply(newImportSpecifiers, getNewImportSpecifiers(namedImports));
139102
139170
  var sortedImportSpecifiers = sortSpecifiers(newImportSpecifiers);
139103
139171
  var importDecl = defaultImports.length > 0
139104
139172
  ? defaultImports[0]
@@ -139308,6 +139376,21 @@ var ts;
139308
139376
  return 6;
139309
139377
  }
139310
139378
  }
139379
+ function getNewImportSpecifiers(namedImports) {
139380
+ return ts.flatMap(namedImports, function (namedImport) {
139381
+ return ts.map(tryGetNamedBindingElements(namedImport), function (importSpecifier) {
139382
+ return importSpecifier.name && importSpecifier.propertyName && importSpecifier.name.escapedText === importSpecifier.propertyName.escapedText
139383
+ ? ts.factory.updateImportSpecifier(importSpecifier, importSpecifier.isTypeOnly, /*propertyName*/ undefined, importSpecifier.name)
139384
+ : importSpecifier;
139385
+ });
139386
+ });
139387
+ }
139388
+ function tryGetNamedBindingElements(namedImport) {
139389
+ var _a;
139390
+ return ((_a = namedImport.importClause) === null || _a === void 0 ? void 0 : _a.namedBindings) && ts.isNamedImports(namedImport.importClause.namedBindings)
139391
+ ? namedImport.importClause.namedBindings.elements
139392
+ : undefined;
139393
+ }
139311
139394
  })(OrganizeImports = ts.OrganizeImports || (ts.OrganizeImports = {}));
139312
139395
  })(ts || (ts = {}));
139313
139396
  /* @internal */
@@ -141021,12 +141104,12 @@ var ts;
141021
141104
  : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
141022
141105
  }
141023
141106
  SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
141024
- function getArgumentOrParameterListInfo(node, sourceFile) {
141107
+ function getArgumentOrParameterListInfo(node, position, sourceFile) {
141025
141108
  var info = getArgumentOrParameterListAndIndex(node, sourceFile);
141026
141109
  if (!info)
141027
141110
  return undefined;
141028
141111
  var list = info.list, argumentIndex = info.argumentIndex;
141029
- var argumentCount = getArgumentCount(list);
141112
+ var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
141030
141113
  if (argumentIndex !== 0) {
141031
141114
  ts.Debug.assertLessThan(argumentIndex, argumentCount);
141032
141115
  }
@@ -141072,7 +141155,7 @@ var ts;
141072
141155
  // Case 3:
141073
141156
  // foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
141074
141157
  // Find out if 'node' is an argument, a type argument, or neither
141075
- var info = getArgumentOrParameterListInfo(node, sourceFile);
141158
+ var info = getArgumentOrParameterListInfo(node, position, sourceFile);
141076
141159
  if (!info)
141077
141160
  return undefined;
141078
141161
  var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -141141,8 +141224,8 @@ var ts;
141141
141224
  function countBinaryExpressionParameters(b) {
141142
141225
  return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
141143
141226
  }
141144
- function tryGetParameterInfo(startingToken, _position, sourceFile, checker) {
141145
- var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
141227
+ function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
141228
+ var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
141146
141229
  if (!info)
141147
141230
  return undefined;
141148
141231
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -141154,7 +141237,7 @@ var ts;
141154
141237
  var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
141155
141238
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
141156
141239
  }
141157
- function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
141240
+ function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
141158
141241
  if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
141159
141242
  return undefined;
141160
141243
  var parent = startingToken.parent;
@@ -141163,7 +141246,7 @@ var ts;
141163
141246
  case 168 /* MethodDeclaration */:
141164
141247
  case 212 /* FunctionExpression */:
141165
141248
  case 213 /* ArrowFunction */:
141166
- var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
141249
+ var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
141167
141250
  if (!info)
141168
141251
  return undefined;
141169
141252
  var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -141210,7 +141293,7 @@ var ts;
141210
141293
  }
141211
141294
  return argumentIndex;
141212
141295
  }
141213
- function getArgumentCount(argumentsList) {
141296
+ function getArgumentCount(argumentsList, ignoreTrailingComma) {
141214
141297
  // The argument count for a list is normally the number of non-comma children it has.
141215
141298
  // For example, if you have "Foo(a,b)" then there will be three children of the arg
141216
141299
  // list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
@@ -141224,7 +141307,7 @@ var ts;
141224
141307
  // arg count of 3.
141225
141308
  var listChildren = argumentsList.getChildren();
141226
141309
  var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
141227
- if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
141310
+ if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
141228
141311
  argumentCount++;
141229
141312
  }
141230
141313
  return argumentCount;
@@ -142678,6 +142761,18 @@ var ts;
142678
142761
  }
142679
142762
  }
142680
142763
  }
142764
+ if (documentation.length === 0 && ts.isIdentifier(location) && symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration)) {
142765
+ var declaration = symbol.valueDeclaration;
142766
+ var parent = declaration.parent;
142767
+ if (ts.isIdentifier(declaration.name) && ts.isObjectBindingPattern(parent)) {
142768
+ var name_4 = ts.getTextOfIdentifierOrLiteral(declaration.name);
142769
+ var objectType = typeChecker.getTypeAtLocation(parent);
142770
+ documentation = ts.firstDefined(objectType.isUnion() ? objectType.types : [objectType], function (t) {
142771
+ var prop = t.getProperty(name_4);
142772
+ return prop ? prop.getDocumentationComment(typeChecker) : undefined;
142773
+ }) || ts.emptyArray;
142774
+ }
142775
+ }
142681
142776
  if (tags.length === 0 && !hasMultipleSignatures) {
142682
142777
  tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
142683
142778
  }
@@ -156211,51 +156306,53 @@ var ts;
156211
156306
  (function (ts) {
156212
156307
  var refactor;
156213
156308
  (function (refactor) {
156309
+ var _a;
156214
156310
  var refactorName = "Convert import";
156215
- var namespaceToNamedAction = {
156216
- name: "Convert namespace import to named imports",
156217
- description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
156218
- kind: "refactor.rewrite.import.named",
156219
- };
156220
- var namedToNamespaceAction = {
156221
- name: "Convert named imports to namespace import",
156222
- description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
156223
- kind: "refactor.rewrite.import.namespace",
156224
- };
156311
+ var actions = (_a = {},
156312
+ _a[0 /* Named */] = {
156313
+ name: "Convert namespace import to named imports",
156314
+ description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
156315
+ kind: "refactor.rewrite.import.named",
156316
+ },
156317
+ _a[2 /* Namespace */] = {
156318
+ name: "Convert named imports to namespace import",
156319
+ description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
156320
+ kind: "refactor.rewrite.import.namespace",
156321
+ },
156322
+ _a[1 /* Default */] = {
156323
+ name: "Convert named imports to default import",
156324
+ description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
156325
+ kind: "refactor.rewrite.import.default",
156326
+ },
156327
+ _a);
156225
156328
  refactor.registerRefactor(refactorName, {
156226
- kinds: [
156227
- namespaceToNamedAction.kind,
156228
- namedToNamespaceAction.kind
156229
- ],
156329
+ kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
156230
156330
  getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
156231
- var info = getImportToConvert(context, context.triggerReason === "invoked");
156331
+ var info = getImportConversionInfo(context, context.triggerReason === "invoked");
156232
156332
  if (!info)
156233
156333
  return ts.emptyArray;
156234
156334
  if (!refactor.isRefactorErrorInfo(info)) {
156235
- var namespaceImport = info.kind === 267 /* NamespaceImport */;
156236
- var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
156335
+ var action = actions[info.convertTo];
156237
156336
  return [{ name: refactorName, description: action.description, actions: [action] }];
156238
156337
  }
156239
156338
  if (context.preferences.provideRefactorNotApplicableReason) {
156240
- return [
156241
- { name: refactorName, description: namespaceToNamedAction.description,
156242
- actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] },
156243
- { name: refactorName, description: namedToNamespaceAction.description,
156244
- actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] }
156245
- ];
156339
+ return ts.getOwnValues(actions).map(function (action) { return ({
156340
+ name: refactorName,
156341
+ description: action.description,
156342
+ actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
156343
+ }); });
156246
156344
  }
156247
156345
  return ts.emptyArray;
156248
156346
  },
156249
156347
  getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
156250
- ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
156251
- var info = getImportToConvert(context);
156348
+ ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
156349
+ var info = getImportConversionInfo(context);
156252
156350
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
156253
156351
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
156254
156352
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
156255
156353
  }
156256
156354
  });
156257
- // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`.
156258
- function getImportToConvert(context, considerPartialSpans) {
156355
+ function getImportConversionInfo(context, considerPartialSpans) {
156259
156356
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
156260
156357
  var file = context.file;
156261
156358
  var span = ts.getRefactorContextSpan(context);
@@ -156274,15 +156371,23 @@ var ts;
156274
156371
  if (!importClause.namedBindings) {
156275
156372
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
156276
156373
  }
156277
- return importClause.namedBindings;
156374
+ if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
156375
+ return { convertTo: 0 /* Named */, import: importClause.namedBindings };
156376
+ }
156377
+ var compilerOptions = context.program.getCompilerOptions();
156378
+ var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
156379
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
156380
+ return shouldUseDefault
156381
+ ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
156382
+ : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
156278
156383
  }
156279
- function doChange(sourceFile, program, changes, toConvert) {
156384
+ function doChange(sourceFile, program, changes, info) {
156280
156385
  var checker = program.getTypeChecker();
156281
- if (toConvert.kind === 267 /* NamespaceImport */) {
156282
- doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
156386
+ if (info.convertTo === 0 /* Named */) {
156387
+ doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
156283
156388
  }
156284
156389
  else {
156285
- doChangeNamedToNamespace(sourceFile, checker, changes, toConvert);
156390
+ doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
156286
156391
  }
156287
156392
  }
156288
156393
  function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -156332,7 +156437,7 @@ var ts;
156332
156437
  function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
156333
156438
  return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
156334
156439
  }
156335
- function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) {
156440
+ function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
156336
156441
  var importDecl = toConvert.parent.parent;
156337
156442
  var moduleSpecifier = importDecl.moduleSpecifier;
156338
156443
  var toConvertSymbols = new ts.Set();
@@ -156383,7 +156488,9 @@ var ts;
156383
156488
  var element = _a[_i];
156384
156489
  _loop_17(element);
156385
156490
  }
156386
- changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
156491
+ changes.replaceNode(sourceFile, toConvert, shouldUseDefault
156492
+ ? ts.factory.createIdentifier(namespaceImportName)
156493
+ : ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
156387
156494
  if (neededNamedImports.size) {
156388
156495
  var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
156389
156496
  return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
@@ -156391,6 +156498,13 @@ var ts;
156391
156498
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
156392
156499
  }
156393
156500
  }
156501
+ function isExportEqualsModule(moduleSpecifier, checker) {
156502
+ var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
156503
+ if (!externalModule)
156504
+ return false;
156505
+ var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
156506
+ return externalModule !== exportEquals;
156507
+ }
156394
156508
  function updateImport(old, defaultImportName, elements) {
156395
156509
  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);
156396
156510
  }
@@ -159670,7 +159784,7 @@ var ts;
159670
159784
  var convertParamsToDestructuredObject;
159671
159785
  (function (convertParamsToDestructuredObject) {
159672
159786
  var refactorName = "Convert parameters to destructured object";
159673
- var minimumParameterLength = 2;
159787
+ var minimumParameterLength = 1;
159674
159788
  var refactorDescription = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object);
159675
159789
  var toDestructuredAction = {
159676
159790
  name: refactorName,