typescript 4.6.0-dev.20220204 → 4.6.0-dev.20220208

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.20220204";
103
+ ts.version = ts.versionMajorMinor + ".0-dev.20220208";
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?"),
@@ -59045,7 +59044,7 @@ var ts;
59045
59044
  }
59046
59045
  function getImpliedConstraint(type, checkNode, extendsNode) {
59047
59046
  return isUnaryTupleTypeNode(checkNode) && isUnaryTupleTypeNode(extendsNode) ? getImpliedConstraint(type, checkNode.elements[0], extendsNode.elements[0]) :
59048
- getActualTypeVariable(getTypeFromTypeNode(checkNode)) === type ? getTypeFromTypeNode(extendsNode) :
59047
+ getActualTypeVariable(getTypeFromTypeNode(checkNode)) === getActualTypeVariable(type) ? getTypeFromTypeNode(extendsNode) :
59049
59048
  undefined;
59050
59049
  }
59051
59050
  function getConditionalFlowTypeOfType(type, node) {
@@ -72952,23 +72951,6 @@ var ts;
72952
72951
  if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
72953
72952
  grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
72954
72953
  }
72955
- if ((lexicallyScopedSymbol === null || lexicallyScopedSymbol === void 0 ? void 0 : lexicallyScopedSymbol.valueDeclaration) && (ts.getEmitScriptTarget(compilerOptions) === 99 /* ESNext */ && !useDefineForClassFields)) {
72956
- var lexicalClass_1 = ts.getContainingClass(lexicallyScopedSymbol.valueDeclaration);
72957
- var parentStaticFieldInitializer = ts.findAncestor(node, function (n) {
72958
- if (n === lexicalClass_1)
72959
- return "quit";
72960
- if (ts.isPropertyDeclaration(n.parent) && ts.hasStaticModifier(n.parent) && n.parent.initializer === n && n.parent.parent === lexicalClass_1) {
72961
- return true;
72962
- }
72963
- return false;
72964
- });
72965
- if (parentStaticFieldInitializer) {
72966
- var parentStaticFieldInitializerSymbol = getSymbolOfNode(parentStaticFieldInitializer.parent);
72967
- ts.Debug.assert(parentStaticFieldInitializerSymbol, "Initializer without declaration symbol");
72968
- 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));
72969
- ts.addRelatedInfo(diagnostic, ts.createDiagnosticForNode(parentStaticFieldInitializer.parent, ts.Diagnostics.Initializer_for_property_0, ts.symbolName(parentStaticFieldInitializerSymbol)));
72970
- }
72971
- }
72972
72954
  if (isAnyLike) {
72973
72955
  if (lexicallyScopedSymbol) {
72974
72956
  return isErrorType(apparentType) ? errorType : apparentType;
@@ -78604,9 +78586,6 @@ var ts;
78604
78586
  checkGrammarComputedPropertyName(node.name);
78605
78587
  checkVariableLikeDeclaration(node);
78606
78588
  setNodeLinksForPrivateIdentifierScope(node);
78607
- if (ts.isPrivateIdentifier(node.name) && ts.hasStaticModifier(node) && node.initializer && languageVersion === 99 /* ESNext */ && !compilerOptions.useDefineForClassFields) {
78608
- 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);
78609
- }
78610
78589
  // property signatures already report "initializer not allowed in ambient context" elsewhere
78611
78590
  if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
78612
78591
  error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
@@ -92296,10 +92275,12 @@ var ts;
92296
92275
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
92297
92276
  var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
92298
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 */;
92299
92281
  // We don't need to transform `super` property access when targeting ES5, ES3 because
92300
92282
  // the es2015 transformation handles those.
92301
- var shouldTransformSuperInStaticInitializers = (languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields) && languageVersion >= 2 /* ES2015 */;
92302
- var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
92283
+ var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
92303
92284
  var previousOnSubstituteNode = context.onSubstituteNode;
92304
92285
  context.onSubstituteNode = onSubstituteNode;
92305
92286
  var previousOnEmitNode = context.onEmitNode;
@@ -92528,6 +92509,10 @@ var ts;
92528
92509
  ts.Debug.assert(!ts.some(node.decorators));
92529
92510
  if (ts.isPrivateIdentifier(node.name)) {
92530
92511
  if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
92512
+ if (ts.isStatic(node)) {
92513
+ // static fields are left as is
92514
+ return ts.visitEachChild(node, visitor, context);
92515
+ }
92531
92516
  // Initializer is elided as the field is initialized in transformConstructor.
92532
92517
  return factory.updatePropertyDeclaration(node,
92533
92518
  /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
@@ -92549,6 +92534,22 @@ var ts;
92549
92534
  if (expr && !ts.isSimpleInlineableExpression(expr)) {
92550
92535
  getPendingExpressions().push(expr);
92551
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
+ }
92552
92553
  return undefined;
92553
92554
  }
92554
92555
  function createPrivateIdentifierAccess(info, receiver) {
@@ -92936,7 +92937,6 @@ var ts;
92936
92937
  if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
92937
92938
  enableSubstitutionForClassStaticThisOrSuperReference();
92938
92939
  }
92939
- var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92940
92940
  // If a class has private static fields, or a static field has a `this` or `super` reference,
92941
92941
  // then we need to allocate a temp variable to hold on to that reference.
92942
92942
  var pendingClassReferenceAssignment;
@@ -92964,6 +92964,7 @@ var ts;
92964
92964
  // From ES6 specification:
92965
92965
  // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
92966
92966
  // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
92967
+ var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92967
92968
  if (ts.some(staticProperties)) {
92968
92969
  addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
92969
92970
  }
@@ -93002,7 +93003,7 @@ var ts;
93002
93003
  }
93003
93004
  var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
93004
93005
  /*typeParameters*/ undefined, ts.visitNodes(node.heritageClauses, heritageClauseVisitor, ts.isHeritageClause), transformClassMembers(node, isDerivedClass));
93005
- 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); });
93006
93007
  if (hasTransformableStatics || ts.some(pendingExpressions)) {
93007
93008
  if (isDecoratedClassDeclaration) {
93008
93009
  ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
@@ -93049,6 +93050,7 @@ var ts;
93049
93050
  return undefined;
93050
93051
  }
93051
93052
  function transformClassMembers(node, isDerivedClass) {
93053
+ var members = [];
93052
93054
  if (shouldTransformPrivateElementsOrClassStaticBlocks) {
93053
93055
  // Declare private names.
93054
93056
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
@@ -93061,12 +93063,20 @@ var ts;
93061
93063
  createBrandCheckWeakSetForPrivateMethods();
93062
93064
  }
93063
93065
  }
93064
- var members = [];
93065
93066
  var constructor = transformConstructor(node, isDerivedClass);
93067
+ var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
93066
93068
  if (constructor) {
93067
93069
  members.push(constructor);
93068
93070
  }
93069
- 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);
93070
93080
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
93071
93081
  }
93072
93082
  function createBrandCheckWeakSetForPrivateMethods() {
@@ -93209,24 +93219,34 @@ var ts;
93209
93219
  function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
93210
93220
  for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
93211
93221
  var property = properties_7[_i];
93212
- var expression = ts.isClassStaticBlockDeclaration(property) ?
93213
- transformClassStaticBlockDeclaration(property) :
93214
- transformProperty(property, receiver);
93215
- if (!expression) {
93222
+ if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
93223
+ continue;
93224
+ }
93225
+ var statement = transformPropertyOrClassStaticBlock(property, receiver);
93226
+ if (!statement) {
93216
93227
  continue;
93217
93228
  }
93218
- var statement = factory.createExpressionStatement(expression);
93219
- ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93220
- ts.setCommentRange(statement, property);
93221
- ts.setOriginalNode(statement, property);
93222
- // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93223
- // `statement` and `expression` have a copy of the synthesized comments.
93224
- // Drop the comments from expression to avoid printing them twice.
93225
- ts.setSyntheticLeadingComments(expression, undefined);
93226
- ts.setSyntheticTrailingComments(expression, undefined);
93227
93229
  statements.push(statement);
93228
93230
  }
93229
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
+ }
93230
93250
  /**
93231
93251
  * Generates assignment expressions for property initializers.
93232
93252
  *
@@ -126689,15 +126709,35 @@ var ts;
126689
126709
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
126690
126710
  }
126691
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;
126692
126726
  function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
126693
- if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
126727
+ if (needsNameFromDeclaration(symbol)) {
126694
126728
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
126695
- 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)
126696
126730
  || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
126697
126731
  }
126698
126732
  return symbol.name;
126699
126733
  }
126700
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
+ }
126701
126741
  function getSymbolParentOrFail(symbol) {
126702
126742
  var _a;
126703
126743
  return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " +
@@ -126867,9 +126907,11 @@ var ts;
126867
126907
  // 3. Otherwise, we have a default/namespace import that can be imported by any name, and
126868
126908
  // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
126869
126909
  // get a better name.
126870
- var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126910
+ var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126871
126911
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
126872
- : 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];
126873
126915
  var moduleName = ts.stripQuotes(moduleSymbol.name);
126874
126916
  var id = exportInfoId++;
126875
126917
  var target = ts.skipAlias(symbol, checker);
@@ -126877,10 +126919,11 @@ var ts;
126877
126919
  var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
126878
126920
  if (!storedSymbol || !storedModuleSymbol)
126879
126921
  symbols.set(id, [symbol, moduleSymbol]);
126880
- exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
126922
+ exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
126881
126923
  id: id,
126882
126924
  symbolTableKey: symbolTableKey,
126883
- symbolName: importedName,
126925
+ symbolName: symbolName,
126926
+ capitalizedSymbolName: capitalizedSymbolName,
126884
126927
  moduleName: moduleName,
126885
126928
  moduleFile: moduleFile,
126886
126929
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
@@ -126898,21 +126941,18 @@ var ts;
126898
126941
  var result = exportInfo.get(key);
126899
126942
  return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
126900
126943
  },
126901
- forEach: function (importingFile, action) {
126944
+ search: function (importingFile, preferCapitalized, matches, action) {
126902
126945
  if (importingFile !== usableByFileName)
126903
126946
  return;
126904
126947
  exportInfo.forEach(function (info, key) {
126905
126948
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
126906
- var rehydrated = info.map(rehydrateCachedInfo);
126907
- var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126908
- if (filtered.length) {
126909
- action(filtered, function (preferCapitalized) {
126910
- var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
126911
- var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126912
- return preferCapitalized
126913
- ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
126914
- : symbolName;
126915
- }, !!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
+ }
126916
126956
  }
126917
126957
  });
126918
126958
  },
@@ -130288,7 +130328,8 @@ var ts;
130288
130328
  case 103 /* NewKeyword */:
130289
130329
  return checker.getContextualType(parent);
130290
130330
  case 82 /* CaseKeyword */:
130291
- return ts.getSwitchedType(ts.cast(parent, ts.isCaseClause), checker);
130331
+ var caseClause = ts.tryCast(parent, ts.isCaseClause);
130332
+ return caseClause ? ts.getSwitchedType(caseClause, checker) : undefined;
130292
130333
  case 18 /* OpenBraceToken */:
130293
130334
  return ts.isJsxExpression(parent) && !ts.isJsxElement(parent.parent) && !ts.isJsxFragment(parent.parent) ? checker.getContextualTypeForJsxAttribute(parent.parent) : undefined;
130294
130335
  default:
@@ -131028,44 +131069,47 @@ var ts;
131028
131069
  var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
131029
131070
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131030
131071
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
131031
- exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
131032
- var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
131072
+ exportInfo.search(sourceFile.path,
131073
+ /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
131033
131074
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
131034
- return;
131075
+ return false;
131035
131076
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
131036
- return;
131037
- // `targetFlags` should be the same for each `info`
131038
- if (!isTypeOnlyLocation && !importCompletionNode && !(info[0].targetFlags & 111551 /* Value */))
131039
- return;
131040
- if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131041
- return;
131077
+ return false;
131078
+ if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
131079
+ return false;
131080
+ if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131081
+ return false;
131042
131082
  // Do not try to auto-import something with a lowercase first letter for a JSX tag
131043
131083
  var firstChar = symbolName.charCodeAt(0);
131044
131084
  if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
131085
+ return false;
131086
+ if (detailsEntryId)
131087
+ return true;
131088
+ return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
131089
+ }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
131090
+ if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
131091
+ return;
131092
+ }
131093
+ var defaultExportInfo = ts.find(info, isImportableExportInfo);
131094
+ if (!defaultExportInfo) {
131045
131095
  return;
131046
- var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
131047
- if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
131048
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
131049
- if (!defaultExportInfo) {
131050
- return;
131051
- }
131052
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131053
- // (We need to ensure that at least one is importable to show a completion.)
131054
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131055
- var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */;
131056
- var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol;
131057
- pushAutoImportSymbol(symbol, {
131058
- kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131059
- moduleSpecifier: moduleSpecifier,
131060
- symbolName: symbolName,
131061
- exportMapKey: exportMapKey,
131062
- exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
131063
- fileName: exportInfo_1.moduleFileName,
131064
- isDefaultExport: isDefaultExport,
131065
- moduleSymbol: exportInfo_1.moduleSymbol,
131066
- isFromPackageJson: exportInfo_1.isFromPackageJson,
131067
- });
131068
131096
  }
131097
+ // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131098
+ // (We need to ensure that at least one is importable to show a completion.)
131099
+ var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131100
+ var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
131101
+ var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
131102
+ pushAutoImportSymbol(symbol, {
131103
+ kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131104
+ moduleSpecifier: moduleSpecifier,
131105
+ symbolName: symbolName,
131106
+ exportMapKey: exportMapKey,
131107
+ exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
131108
+ fileName: exportInfo.moduleFileName,
131109
+ isDefaultExport: isDefaultExport,
131110
+ moduleSymbol: exportInfo.moduleSymbol,
131111
+ isFromPackageJson: exportInfo.isFromPackageJson,
131112
+ });
131069
131113
  });
131070
131114
  hasUnresolvedAutoImports = context.resolutionLimitExceeded();
131071
131115
  });
@@ -132930,7 +132974,24 @@ var ts;
132930
132974
  function acquireOrUpdateDocument(fileName, path, compilationSettings, key, scriptSnapshot, version, acquiring, scriptKind) {
132931
132975
  scriptKind = ts.ensureScriptKind(fileName, scriptKind);
132932
132976
  var scriptTarget = scriptKind === 6 /* JSON */ ? 100 /* JSON */ : ts.getEmitScriptTarget(compilationSettings);
132977
+ var oldBucketCount = buckets.size;
132933
132978
  var bucket = ts.getOrUpdate(buckets, key, function () { return new ts.Map(); });
132979
+ if (ts.tracing) {
132980
+ if (buckets.size > oldBucketCount) {
132981
+ // It is interesting, but not definitively problematic if a build requires multiple document registry buckets -
132982
+ // perhaps they are for two projects that don't have any overlap.
132983
+ // Bonus: these events can help us interpret the more interesting event below.
132984
+ ts.tracing.instant("session" /* Session */, "createdDocumentRegistryBucket", { configFilePath: compilationSettings.configFilePath, key: key });
132985
+ }
132986
+ // It is fairly suspicious to have one path in two buckets - you'd expect dependencies to have similar configurations.
132987
+ // If this occurs unexpectedly, the fix is likely to synchronize the project settings.
132988
+ // Skip .d.ts files to reduce noise (should also cover most of node_modules).
132989
+ var otherBucketKey = !ts.fileExtensionIs(path, ".d.ts" /* Dts */) &&
132990
+ ts.forEachEntry(buckets, function (bucket, bucketKey) { return bucketKey !== key && bucket.has(path) && bucketKey; });
132991
+ if (otherBucketKey) {
132992
+ ts.tracing.instant("session" /* Session */, "documentRegistryBucketOverlap", { path: path, key1: otherBucketKey, key2: key });
132993
+ }
132994
+ }
132934
132995
  var bucketEntry = bucket.get(path);
132935
132996
  var entry = bucketEntry && getDocumentRegistryEntry(bucketEntry, scriptKind);
132936
132997
  if (!entry && externalCache) {
@@ -137004,7 +137065,27 @@ var ts;
137004
137065
  case 326 /* JSDocAugmentsTag */:
137005
137066
  return withNode(tag.class);
137006
137067
  case 342 /* JSDocTemplateTag */:
137007
- return addComment(tag.typeParameters.map(function (tp) { return tp.getText(); }).join(", "));
137068
+ var templateTag = tag;
137069
+ var displayParts_3 = [];
137070
+ if (templateTag.constraint) {
137071
+ displayParts_3.push(ts.textPart(templateTag.constraint.getText()));
137072
+ }
137073
+ if (ts.length(templateTag.typeParameters)) {
137074
+ if (ts.length(displayParts_3)) {
137075
+ displayParts_3.push(ts.spacePart());
137076
+ }
137077
+ var lastTypeParameter_1 = templateTag.typeParameters[templateTag.typeParameters.length - 1];
137078
+ ts.forEach(templateTag.typeParameters, function (tp) {
137079
+ displayParts_3.push(namePart(tp.getText()));
137080
+ if (lastTypeParameter_1 !== tp) {
137081
+ displayParts_3.push.apply(displayParts_3, [ts.punctuationPart(27 /* CommaToken */), ts.spacePart()]);
137082
+ }
137083
+ });
137084
+ }
137085
+ if (comment) {
137086
+ displayParts_3.push.apply(displayParts_3, __spreadArray([ts.spacePart()], getDisplayPartsFromComment(comment, checker), true));
137087
+ }
137088
+ return displayParts_3;
137008
137089
  case 341 /* JSDocTypeTag */:
137009
137090
  return withNode(tag.typeExpression);
137010
137091
  case 343 /* JSDocTypedefTag */:
@@ -140430,12 +140511,12 @@ var ts;
140430
140511
  : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
140431
140512
  }
140432
140513
  SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
140433
- function getArgumentOrParameterListInfo(node, sourceFile) {
140514
+ function getArgumentOrParameterListInfo(node, position, sourceFile) {
140434
140515
  var info = getArgumentOrParameterListAndIndex(node, sourceFile);
140435
140516
  if (!info)
140436
140517
  return undefined;
140437
140518
  var list = info.list, argumentIndex = info.argumentIndex;
140438
- var argumentCount = getArgumentCount(list);
140519
+ var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
140439
140520
  if (argumentIndex !== 0) {
140440
140521
  ts.Debug.assertLessThan(argumentIndex, argumentCount);
140441
140522
  }
@@ -140481,7 +140562,7 @@ var ts;
140481
140562
  // Case 3:
140482
140563
  // foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
140483
140564
  // Find out if 'node' is an argument, a type argument, or neither
140484
- var info = getArgumentOrParameterListInfo(node, sourceFile);
140565
+ var info = getArgumentOrParameterListInfo(node, position, sourceFile);
140485
140566
  if (!info)
140486
140567
  return undefined;
140487
140568
  var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140550,8 +140631,8 @@ var ts;
140550
140631
  function countBinaryExpressionParameters(b) {
140551
140632
  return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
140552
140633
  }
140553
- function tryGetParameterInfo(startingToken, _position, sourceFile, checker) {
140554
- var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
140634
+ function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
140635
+ var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
140555
140636
  if (!info)
140556
140637
  return undefined;
140557
140638
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140563,7 +140644,7 @@ var ts;
140563
140644
  var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
140564
140645
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
140565
140646
  }
140566
- function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
140647
+ function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
140567
140648
  if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
140568
140649
  return undefined;
140569
140650
  var parent = startingToken.parent;
@@ -140572,7 +140653,7 @@ var ts;
140572
140653
  case 168 /* MethodDeclaration */:
140573
140654
  case 212 /* FunctionExpression */:
140574
140655
  case 213 /* ArrowFunction */:
140575
- var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
140656
+ var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
140576
140657
  if (!info)
140577
140658
  return undefined;
140578
140659
  var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140619,7 +140700,7 @@ var ts;
140619
140700
  }
140620
140701
  return argumentIndex;
140621
140702
  }
140622
- function getArgumentCount(argumentsList) {
140703
+ function getArgumentCount(argumentsList, ignoreTrailingComma) {
140623
140704
  // The argument count for a list is normally the number of non-comma children it has.
140624
140705
  // For example, if you have "Foo(a,b)" then there will be three children of the arg
140625
140706
  // list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
@@ -140633,7 +140714,7 @@ var ts;
140633
140714
  // arg count of 3.
140634
140715
  var listChildren = argumentsList.getChildren();
140635
140716
  var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
140636
- if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
140717
+ if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
140637
140718
  argumentCount++;
140638
140719
  }
140639
140720
  return argumentCount;
@@ -155632,51 +155713,53 @@ var ts;
155632
155713
  (function (ts) {
155633
155714
  var refactor;
155634
155715
  (function (refactor) {
155716
+ var _a;
155635
155717
  var refactorName = "Convert import";
155636
- var namespaceToNamedAction = {
155637
- name: "Convert namespace import to named imports",
155638
- description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
155639
- kind: "refactor.rewrite.import.named",
155640
- };
155641
- var namedToNamespaceAction = {
155642
- name: "Convert named imports to namespace import",
155643
- description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
155644
- kind: "refactor.rewrite.import.namespace",
155645
- };
155718
+ var actions = (_a = {},
155719
+ _a[0 /* Named */] = {
155720
+ name: "Convert namespace import to named imports",
155721
+ description: ts.Diagnostics.Convert_namespace_import_to_named_imports.message,
155722
+ kind: "refactor.rewrite.import.named",
155723
+ },
155724
+ _a[2 /* Namespace */] = {
155725
+ name: "Convert named imports to namespace import",
155726
+ description: ts.Diagnostics.Convert_named_imports_to_namespace_import.message,
155727
+ kind: "refactor.rewrite.import.namespace",
155728
+ },
155729
+ _a[1 /* Default */] = {
155730
+ name: "Convert named imports to default import",
155731
+ description: ts.Diagnostics.Convert_named_imports_to_default_import.message,
155732
+ kind: "refactor.rewrite.import.default",
155733
+ },
155734
+ _a);
155646
155735
  refactor.registerRefactor(refactorName, {
155647
- kinds: [
155648
- namespaceToNamedAction.kind,
155649
- namedToNamespaceAction.kind
155650
- ],
155736
+ kinds: ts.getOwnValues(actions).map(function (a) { return a.kind; }),
155651
155737
  getAvailableActions: function getRefactorActionsToConvertBetweenNamedAndNamespacedImports(context) {
155652
- var info = getImportToConvert(context, context.triggerReason === "invoked");
155738
+ var info = getImportConversionInfo(context, context.triggerReason === "invoked");
155653
155739
  if (!info)
155654
155740
  return ts.emptyArray;
155655
155741
  if (!refactor.isRefactorErrorInfo(info)) {
155656
- var namespaceImport = info.kind === 267 /* NamespaceImport */;
155657
- var action = namespaceImport ? namespaceToNamedAction : namedToNamespaceAction;
155742
+ var action = actions[info.convertTo];
155658
155743
  return [{ name: refactorName, description: action.description, actions: [action] }];
155659
155744
  }
155660
155745
  if (context.preferences.provideRefactorNotApplicableReason) {
155661
- return [
155662
- { name: refactorName, description: namespaceToNamedAction.description,
155663
- actions: [__assign(__assign({}, namespaceToNamedAction), { notApplicableReason: info.error })] },
155664
- { name: refactorName, description: namedToNamespaceAction.description,
155665
- actions: [__assign(__assign({}, namedToNamespaceAction), { notApplicableReason: info.error })] }
155666
- ];
155746
+ return ts.getOwnValues(actions).map(function (action) { return ({
155747
+ name: refactorName,
155748
+ description: action.description,
155749
+ actions: [__assign(__assign({}, action), { notApplicableReason: info.error })]
155750
+ }); });
155667
155751
  }
155668
155752
  return ts.emptyArray;
155669
155753
  },
155670
155754
  getEditsForAction: function getRefactorEditsToConvertBetweenNamedAndNamespacedImports(context, actionName) {
155671
- ts.Debug.assert(actionName === namespaceToNamedAction.name || actionName === namedToNamespaceAction.name, "Unexpected action name");
155672
- var info = getImportToConvert(context);
155755
+ ts.Debug.assert(ts.some(ts.getOwnValues(actions), function (action) { return action.name === actionName; }), "Unexpected action name");
155756
+ var info = getImportConversionInfo(context);
155673
155757
  ts.Debug.assert(info && !refactor.isRefactorErrorInfo(info), "Expected applicable refactor info");
155674
155758
  var edits = ts.textChanges.ChangeTracker.with(context, function (t) { return doChange(context.file, context.program, t, info); });
155675
155759
  return { edits: edits, renameFilename: undefined, renameLocation: undefined };
155676
155760
  }
155677
155761
  });
155678
- // Can convert imports of the form `import * as m from "m";` or `import d, { x, y } from "m";`.
155679
- function getImportToConvert(context, considerPartialSpans) {
155762
+ function getImportConversionInfo(context, considerPartialSpans) {
155680
155763
  if (considerPartialSpans === void 0) { considerPartialSpans = true; }
155681
155764
  var file = context.file;
155682
155765
  var span = ts.getRefactorContextSpan(context);
@@ -155695,15 +155778,23 @@ var ts;
155695
155778
  if (!importClause.namedBindings) {
155696
155779
  return { error: ts.getLocaleSpecificMessage(ts.Diagnostics.Could_not_find_namespace_import_or_named_imports) };
155697
155780
  }
155698
- return importClause.namedBindings;
155781
+ if (importClause.namedBindings.kind === 267 /* NamespaceImport */) {
155782
+ return { convertTo: 0 /* Named */, import: importClause.namedBindings };
155783
+ }
155784
+ var compilerOptions = context.program.getCompilerOptions();
155785
+ var shouldUseDefault = ts.getAllowSyntheticDefaultImports(compilerOptions)
155786
+ && isExportEqualsModule(importClause.parent.moduleSpecifier, context.program.getTypeChecker());
155787
+ return shouldUseDefault
155788
+ ? { convertTo: 1 /* Default */, import: importClause.namedBindings }
155789
+ : { convertTo: 2 /* Namespace */, import: importClause.namedBindings };
155699
155790
  }
155700
- function doChange(sourceFile, program, changes, toConvert) {
155791
+ function doChange(sourceFile, program, changes, info) {
155701
155792
  var checker = program.getTypeChecker();
155702
- if (toConvert.kind === 267 /* NamespaceImport */) {
155703
- doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
155793
+ if (info.convertTo === 0 /* Named */) {
155794
+ doChangeNamespaceToNamed(sourceFile, checker, changes, info.import, ts.getAllowSyntheticDefaultImports(program.getCompilerOptions()));
155704
155795
  }
155705
155796
  else {
155706
- doChangeNamedToNamespace(sourceFile, checker, changes, toConvert);
155797
+ doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, info.import, info.convertTo === 1 /* Default */);
155707
155798
  }
155708
155799
  }
155709
155800
  function doChangeNamespaceToNamed(sourceFile, checker, changes, toConvert, allowSyntheticDefaultImports) {
@@ -155753,7 +155844,7 @@ var ts;
155753
155844
  function getLeftOfPropertyAccessOrQualifiedName(propertyAccessOrQualifiedName) {
155754
155845
  return ts.isPropertyAccessExpression(propertyAccessOrQualifiedName) ? propertyAccessOrQualifiedName.expression : propertyAccessOrQualifiedName.left;
155755
155846
  }
155756
- function doChangeNamedToNamespace(sourceFile, checker, changes, toConvert) {
155847
+ function doChangeNamedToNamespaceOrDefault(sourceFile, checker, changes, toConvert, shouldUseDefault) {
155757
155848
  var importDecl = toConvert.parent.parent;
155758
155849
  var moduleSpecifier = importDecl.moduleSpecifier;
155759
155850
  var toConvertSymbols = new ts.Set();
@@ -155804,7 +155895,9 @@ var ts;
155804
155895
  var element = _a[_i];
155805
155896
  _loop_17(element);
155806
155897
  }
155807
- changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
155898
+ changes.replaceNode(sourceFile, toConvert, shouldUseDefault
155899
+ ? ts.factory.createIdentifier(namespaceImportName)
155900
+ : ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
155808
155901
  if (neededNamedImports.size) {
155809
155902
  var newNamedImports = ts.arrayFrom(neededNamedImports.values()).map(function (element) {
155810
155903
  return ts.factory.createImportSpecifier(element.isTypeOnly, element.propertyName && ts.factory.createIdentifier(element.propertyName.text), ts.factory.createIdentifier(element.name.text));
@@ -155812,6 +155905,13 @@ var ts;
155812
155905
  changes.insertNodeAfter(sourceFile, toConvert.parent.parent, updateImport(importDecl, /*defaultImportName*/ undefined, newNamedImports));
155813
155906
  }
155814
155907
  }
155908
+ function isExportEqualsModule(moduleSpecifier, checker) {
155909
+ var externalModule = checker.resolveExternalModuleName(moduleSpecifier);
155910
+ if (!externalModule)
155911
+ return false;
155912
+ var exportEquals = checker.resolveExternalModuleSymbol(externalModule);
155913
+ return externalModule !== exportEquals;
155914
+ }
155815
155915
  function updateImport(old, defaultImportName, elements) {
155816
155916
  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);
155817
155917
  }
@@ -156667,8 +156767,8 @@ var ts;
156667
156767
  // but a super *method call* simply implies a 'this' reference
156668
156768
  if (node.parent.kind === 207 /* CallExpression */) {
156669
156769
  // Super constructor call
156670
- var containingClass_1 = ts.getContainingClass(node); // TODO:GH#18217
156671
- if (containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
156770
+ var containingClass_1 = ts.getContainingClass(node);
156771
+ if (containingClass_1 === undefined || containingClass_1.pos < span.start || containingClass_1.end >= (span.start + span.length)) {
156672
156772
  (errors || (errors = [])).push(ts.createDiagnosticForNode(node, Messages.cannotExtractSuper));
156673
156773
  return true;
156674
156774
  }
@@ -171487,9 +171587,10 @@ var ts;
171487
171587
  var info = infos && ts.firstOrUndefined(infos);
171488
171588
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
171489
171589
  }
171490
- function combineProjectOutputForReferences(projects, defaultProject, initialLocation) {
171590
+ function combineProjectOutputForReferences(projects, defaultProject, initialLocation, logger) {
171491
171591
  var outputs = [];
171492
171592
  combineProjectOutputWorker(projects, defaultProject, initialLocation, function (project, location, getMappedLocation) {
171593
+ logger.info("Finding references to " + location.fileName + " position " + location.pos + " in project " + project.getProjectName());
171493
171594
  var _loop_8 = function (outputReferencedSymbol) {
171494
171595
  var mappedDefinitionFile = getMappedLocation(project, documentSpanLocation(outputReferencedSymbol.definition));
171495
171596
  var definition = mappedDefinitionFile === undefined ?
@@ -172847,7 +172948,7 @@ var ts;
172847
172948
  var file = server.toNormalizedPath(args.file);
172848
172949
  var projects = this.getProjects(args);
172849
172950
  var position = this.getPositionInFile(args, file);
172850
- var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position });
172951
+ var references = combineProjectOutputForReferences(projects, this.getDefaultProject(args), { fileName: args.file, pos: position }, this.logger);
172851
172952
  if (!simplifiedResult)
172852
172953
  return references;
172853
172954
  var defaultProject = this.getDefaultProject(args);