@typescript-deploys/pr-build 4.6.0-pr-47690-4 → 4.6.0-pr-47717-6

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-insiders.20220203";
103
+ ts.version = ts.versionMajorMinor + ".0-insiders.20220204";
104
104
  /* @internal */
105
105
  var Comparison;
106
106
  (function (Comparison) {
@@ -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}'."),
@@ -59511,7 +59509,7 @@ var ts;
59511
59509
  }
59512
59510
  }
59513
59511
  var fixedLength = properties.length;
59514
- var lengthSymbol = createSymbol(4 /* Property */, "length");
59512
+ var lengthSymbol = createSymbol(4 /* Property */, "length", readonly ? 8 /* Readonly */ : 0);
59515
59513
  if (combinedFlags & 12 /* Variable */) {
59516
59514
  lengthSymbol.type = numberType;
59517
59515
  }
@@ -72952,23 +72950,6 @@ var ts;
72952
72950
  if (assignmentKind && lexicallyScopedSymbol && lexicallyScopedSymbol.valueDeclaration && ts.isMethodDeclaration(lexicallyScopedSymbol.valueDeclaration)) {
72953
72951
  grammarErrorOnNode(right, ts.Diagnostics.Cannot_assign_to_private_method_0_Private_methods_are_not_writable, ts.idText(right));
72954
72952
  }
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
72953
  if (isAnyLike) {
72973
72954
  if (lexicallyScopedSymbol) {
72974
72955
  return isErrorType(apparentType) ? errorType : apparentType;
@@ -78604,9 +78585,6 @@ var ts;
78604
78585
  checkGrammarComputedPropertyName(node.name);
78605
78586
  checkVariableLikeDeclaration(node);
78606
78587
  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
78588
  // property signatures already report "initializer not allowed in ambient context" elsewhere
78611
78589
  if (ts.hasSyntacticModifier(node, 128 /* Abstract */) && node.kind === 166 /* PropertyDeclaration */ && node.initializer) {
78612
78590
  error(node, ts.Diagnostics.Property_0_cannot_have_an_initializer_because_it_is_marked_abstract, ts.declarationNameToString(node.name));
@@ -92296,10 +92274,12 @@ var ts;
92296
92274
  var languageVersion = ts.getEmitScriptTarget(compilerOptions);
92297
92275
  var useDefineForClassFields = ts.getUseDefineForClassFields(compilerOptions);
92298
92276
  var shouldTransformPrivateElementsOrClassStaticBlocks = languageVersion < 9 /* ES2022 */;
92277
+ // We need to transform `this` in a static initializer into a reference to the class
92278
+ // when targeting < ES2022 since the assignment will be moved outside of the class body.
92279
+ var shouldTransformThisInStaticInitializers = languageVersion < 9 /* ES2022 */;
92299
92280
  // We don't need to transform `super` property access when targeting ES5, ES3 because
92300
92281
  // the es2015 transformation handles those.
92301
- var shouldTransformSuperInStaticInitializers = (languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields) && languageVersion >= 2 /* ES2015 */;
92302
- var shouldTransformThisInStaticInitializers = languageVersion <= 8 /* ES2021 */ || !useDefineForClassFields;
92282
+ var shouldTransformSuperInStaticInitializers = shouldTransformThisInStaticInitializers && languageVersion >= 2 /* ES2015 */;
92303
92283
  var previousOnSubstituteNode = context.onSubstituteNode;
92304
92284
  context.onSubstituteNode = onSubstituteNode;
92305
92285
  var previousOnEmitNode = context.onEmitNode;
@@ -92528,6 +92508,10 @@ var ts;
92528
92508
  ts.Debug.assert(!ts.some(node.decorators));
92529
92509
  if (ts.isPrivateIdentifier(node.name)) {
92530
92510
  if (!shouldTransformPrivateElementsOrClassStaticBlocks) {
92511
+ if (ts.isStatic(node)) {
92512
+ // static fields are left as is
92513
+ return ts.visitEachChild(node, visitor, context);
92514
+ }
92531
92515
  // Initializer is elided as the field is initialized in transformConstructor.
92532
92516
  return factory.updatePropertyDeclaration(node,
92533
92517
  /*decorators*/ undefined, ts.visitNodes(node.modifiers, visitor, ts.isModifier), node.name,
@@ -92549,6 +92533,22 @@ var ts;
92549
92533
  if (expr && !ts.isSimpleInlineableExpression(expr)) {
92550
92534
  getPendingExpressions().push(expr);
92551
92535
  }
92536
+ if (ts.isStatic(node) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
92537
+ var initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
92538
+ if (initializerStatement) {
92539
+ var staticBlock = factory.createClassStaticBlockDeclaration(
92540
+ /*decorators*/ undefined,
92541
+ /*modifiers*/ undefined, factory.createBlock([initializerStatement]));
92542
+ ts.setOriginalNode(staticBlock, node);
92543
+ ts.setCommentRange(staticBlock, node);
92544
+ // Set the comment range for the statement to an empty synthetic range
92545
+ // and drop synthetic comments from the statement to avoid printing them twice.
92546
+ ts.setCommentRange(initializerStatement, { pos: -1, end: -1 });
92547
+ ts.setSyntheticLeadingComments(initializerStatement, undefined);
92548
+ ts.setSyntheticTrailingComments(initializerStatement, undefined);
92549
+ return staticBlock;
92550
+ }
92551
+ }
92552
92552
  return undefined;
92553
92553
  }
92554
92554
  function createPrivateIdentifierAccess(info, receiver) {
@@ -92936,7 +92936,6 @@ var ts;
92936
92936
  if (facts & 8 /* NeedsSubstitutionForThisInClassStaticField */) {
92937
92937
  enableSubstitutionForClassStaticThisOrSuperReference();
92938
92938
  }
92939
- var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92940
92939
  // If a class has private static fields, or a static field has a `this` or `super` reference,
92941
92940
  // then we need to allocate a temp variable to hold on to that reference.
92942
92941
  var pendingClassReferenceAssignment;
@@ -92964,6 +92963,7 @@ var ts;
92964
92963
  // From ES6 specification:
92965
92964
  // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using
92966
92965
  // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration.
92966
+ var staticProperties = ts.getStaticPropertiesAndClassStaticBlock(node);
92967
92967
  if (ts.some(staticProperties)) {
92968
92968
  addPropertyOrClassStaticBlockStatements(statements, staticProperties, factory.getInternalName(node));
92969
92969
  }
@@ -93002,7 +93002,7 @@ var ts;
93002
93002
  }
93003
93003
  var classExpression = factory.updateClassExpression(node, ts.visitNodes(node.decorators, visitor, ts.isDecorator), node.modifiers, node.name,
93004
93004
  /*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)); });
93005
+ var hasTransformableStatics = shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(staticPropertiesOrClassStaticBlocks, function (p) { return ts.isClassStaticBlockDeclaration(p) || !!p.initializer || ts.isPrivateIdentifier(p.name); });
93006
93006
  if (hasTransformableStatics || ts.some(pendingExpressions)) {
93007
93007
  if (isDecoratedClassDeclaration) {
93008
93008
  ts.Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration.");
@@ -93049,6 +93049,7 @@ var ts;
93049
93049
  return undefined;
93050
93050
  }
93051
93051
  function transformClassMembers(node, isDerivedClass) {
93052
+ var members = [];
93052
93053
  if (shouldTransformPrivateElementsOrClassStaticBlocks) {
93053
93054
  // Declare private names.
93054
93055
  for (var _i = 0, _a = node.members; _i < _a.length; _i++) {
@@ -93061,12 +93062,20 @@ var ts;
93061
93062
  createBrandCheckWeakSetForPrivateMethods();
93062
93063
  }
93063
93064
  }
93064
- var members = [];
93065
93065
  var constructor = transformConstructor(node, isDerivedClass);
93066
+ var visitedMembers = ts.visitNodes(node.members, classElementVisitor, ts.isClassElement);
93066
93067
  if (constructor) {
93067
93068
  members.push(constructor);
93068
93069
  }
93069
- ts.addRange(members, ts.visitNodes(node.members, classElementVisitor, ts.isClassElement));
93070
+ if (!shouldTransformPrivateElementsOrClassStaticBlocks && ts.some(pendingExpressions)) {
93071
+ members.push(factory.createClassStaticBlockDeclaration(
93072
+ /*decorators*/ undefined,
93073
+ /*modifiers*/ undefined, factory.createBlock([
93074
+ factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
93075
+ ])));
93076
+ pendingExpressions = undefined;
93077
+ }
93078
+ ts.addRange(members, visitedMembers);
93070
93079
  return ts.setTextRange(factory.createNodeArray(members), /*location*/ node.members);
93071
93080
  }
93072
93081
  function createBrandCheckWeakSetForPrivateMethods() {
@@ -93209,24 +93218,34 @@ var ts;
93209
93218
  function addPropertyOrClassStaticBlockStatements(statements, properties, receiver) {
93210
93219
  for (var _i = 0, properties_7 = properties; _i < properties_7.length; _i++) {
93211
93220
  var property = properties_7[_i];
93212
- var expression = ts.isClassStaticBlockDeclaration(property) ?
93213
- transformClassStaticBlockDeclaration(property) :
93214
- transformProperty(property, receiver);
93215
- if (!expression) {
93221
+ if (ts.isStatic(property) && !shouldTransformPrivateElementsOrClassStaticBlocks && !useDefineForClassFields) {
93222
+ continue;
93223
+ }
93224
+ var statement = transformPropertyOrClassStaticBlock(property, receiver);
93225
+ if (!statement) {
93216
93226
  continue;
93217
93227
  }
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
93228
  statements.push(statement);
93228
93229
  }
93229
93230
  }
93231
+ function transformPropertyOrClassStaticBlock(property, receiver) {
93232
+ var expression = ts.isClassStaticBlockDeclaration(property) ?
93233
+ transformClassStaticBlockDeclaration(property) :
93234
+ transformProperty(property, receiver);
93235
+ if (!expression) {
93236
+ return undefined;
93237
+ }
93238
+ var statement = factory.createExpressionStatement(expression);
93239
+ ts.setSourceMapRange(statement, ts.moveRangePastModifiers(property));
93240
+ ts.setCommentRange(statement, property);
93241
+ ts.setOriginalNode(statement, property);
93242
+ // `setOriginalNode` *copies* the `emitNode` from `property`, so now both
93243
+ // `statement` and `expression` have a copy of the synthesized comments.
93244
+ // Drop the comments from expression to avoid printing them twice.
93245
+ ts.setSyntheticLeadingComments(expression, undefined);
93246
+ ts.setSyntheticTrailingComments(expression, undefined);
93247
+ return statement;
93248
+ }
93230
93249
  /**
93231
93250
  * Generates assignment expressions for property initializers.
93232
93251
  *
@@ -123349,23 +123368,12 @@ var ts;
123349
123368
  PackageJsonAutoImportPreference[PackageJsonAutoImportPreference["On"] = 1] = "On";
123350
123369
  PackageJsonAutoImportPreference[PackageJsonAutoImportPreference["Auto"] = 2] = "Auto";
123351
123370
  })(PackageJsonAutoImportPreference = ts.PackageJsonAutoImportPreference || (ts.PackageJsonAutoImportPreference = {}));
123352
- /* @internal */
123353
- var ProjectReferenceAutoImportPreference;
123354
- (function (ProjectReferenceAutoImportPreference) {
123355
- ProjectReferenceAutoImportPreference[ProjectReferenceAutoImportPreference["Off"] = 0] = "Off";
123356
- ProjectReferenceAutoImportPreference[ProjectReferenceAutoImportPreference["On"] = 1] = "On";
123357
- })(ProjectReferenceAutoImportPreference = ts.ProjectReferenceAutoImportPreference || (ts.ProjectReferenceAutoImportPreference = {}));
123358
123371
  var LanguageServiceMode;
123359
123372
  (function (LanguageServiceMode) {
123360
123373
  LanguageServiceMode[LanguageServiceMode["Semantic"] = 0] = "Semantic";
123361
123374
  LanguageServiceMode[LanguageServiceMode["PartialSemantic"] = 1] = "PartialSemantic";
123362
123375
  LanguageServiceMode[LanguageServiceMode["Syntactic"] = 2] = "Syntactic";
123363
123376
  })(LanguageServiceMode = ts.LanguageServiceMode || (ts.LanguageServiceMode = {}));
123364
- var AutoImportSourceKind;
123365
- (function (AutoImportSourceKind) {
123366
- AutoImportSourceKind[AutoImportSourceKind["Program"] = 1] = "Program";
123367
- AutoImportSourceKind[AutoImportSourceKind["PackageJson"] = 2] = "PackageJson";
123368
- })(AutoImportSourceKind = ts.AutoImportSourceKind || (ts.AutoImportSourceKind = {}));
123369
123377
  /* @internal */
123370
123378
  ts.emptyOptions = {};
123371
123379
  var SemanticClassificationFormat;
@@ -126700,15 +126708,35 @@ var ts;
126700
126708
  return ts.isArray(valueOrArray) ? ts.first(valueOrArray) : valueOrArray;
126701
126709
  }
126702
126710
  ts.firstOrOnly = firstOrOnly;
126711
+ function getNamesForExportedSymbol(symbol, scriptTarget) {
126712
+ if (needsNameFromDeclaration(symbol)) {
126713
+ var fromDeclaration = getDefaultLikeExportNameFromDeclaration(symbol);
126714
+ if (fromDeclaration)
126715
+ return fromDeclaration;
126716
+ var fileNameCase = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ false);
126717
+ var capitalized = ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, /*preferCapitalized*/ true);
126718
+ if (fileNameCase === capitalized)
126719
+ return fileNameCase;
126720
+ return [fileNameCase, capitalized];
126721
+ }
126722
+ return symbol.name;
126723
+ }
126724
+ ts.getNamesForExportedSymbol = getNamesForExportedSymbol;
126703
126725
  function getNameForExportedSymbol(symbol, scriptTarget, preferCapitalized) {
126704
- if (!(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */)) {
126726
+ if (needsNameFromDeclaration(symbol)) {
126705
126727
  // Name of "export default foo;" is "foo". Name of "export default 0" is the filename converted to camelCase.
126706
- 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; })
126728
+ return getDefaultLikeExportNameFromDeclaration(symbol)
126707
126729
  || ts.codefix.moduleSymbolToValidIdentifier(getSymbolParentOrFail(symbol), scriptTarget, !!preferCapitalized);
126708
126730
  }
126709
126731
  return symbol.name;
126710
126732
  }
126711
126733
  ts.getNameForExportedSymbol = getNameForExportedSymbol;
126734
+ function needsNameFromDeclaration(symbol) {
126735
+ return !(symbol.flags & 33554432 /* Transient */) && (symbol.escapedName === "export=" /* ExportEquals */ || symbol.escapedName === "default" /* Default */);
126736
+ }
126737
+ function getDefaultLikeExportNameFromDeclaration(symbol) {
126738
+ 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; });
126739
+ }
126712
126740
  function getSymbolParentOrFail(symbol) {
126713
126741
  var _a;
126714
126742
  return ts.Debug.checkDefined(symbol.parent, "Symbol parent was undefined. Flags: " + ts.Debug.formatSymbolFlags(symbol.flags) + ". " +
@@ -126800,33 +126828,6 @@ var ts;
126800
126828
  return __assign(__assign({}, options), { semicolons: shouldRemoveSemicolons ? ts.SemicolonPreference.Remove : ts.SemicolonPreference.Ignore });
126801
126829
  }
126802
126830
  ts.getFormatCodeSettingsForWriting = getFormatCodeSettingsForWriting;
126803
- function getProgramForAutoImport(source, program, host) {
126804
- var _a, _b;
126805
- switch (source) {
126806
- case 1 /* Program */:
126807
- return program;
126808
- case 2 /* PackageJson */:
126809
- return ts.Debug.checkDefined((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host), "Could not retrieve package.json AutoImportProvider");
126810
- default:
126811
- return ts.Debug.checkDefined((_b = host.getProgramForReferencedProject) === null || _b === void 0 ? void 0 : _b.call(host, source), "Could not retrieve program for auto-importing from referenced project");
126812
- }
126813
- }
126814
- ts.getProgramForAutoImport = getProgramForAutoImport;
126815
- function createMemoizedGetProgramForAutoImport(program, host) {
126816
- return ts.memoizeOne(function (source) { return getProgramForAutoImport(source, program, host); });
126817
- }
126818
- ts.createMemoizedGetProgramForAutoImport = createMemoizedGetProgramForAutoImport;
126819
- function getAutoImportPreferences(preferences) {
126820
- var includePackageJson = preferences.includePackageJsonAutoImports === "off" ? 0 /* Off */ :
126821
- preferences.includePackageJsonAutoImports === "on" ? 1 /* On */ :
126822
- 2 /* Auto */;
126823
- // TODO: flip default back to "off" if shipping as an opt-in experiment.
126824
- // Needs to default to "on" until VS Code is able to set it.
126825
- var includeProjectReferences = preferences.includeProjectReferenceAutoImports === "off" ? 0 /* Off */ :
126826
- 1 /* On */;
126827
- return { includePackageJson: includePackageJson, includeProjectReferences: includeProjectReferences };
126828
- }
126829
- ts.getAutoImportPreferences = getAutoImportPreferences;
126830
126831
  // #endregion
126831
126832
  })(ts || (ts = {}));
126832
126833
  /*@internal*/
@@ -126870,7 +126871,7 @@ var ts;
126870
126871
  symbols.clear();
126871
126872
  usableByFileName = undefined;
126872
126873
  },
126873
- add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, source, checker) {
126874
+ add: function (importingFile, symbol, symbolTableKey, moduleSymbol, moduleFile, exportKind, isFromPackageJson, checker) {
126874
126875
  if (importingFile !== usableByFileName) {
126875
126876
  cache.clear();
126876
126877
  usableByFileName = importingFile;
@@ -126905,9 +126906,11 @@ var ts;
126905
126906
  // 3. Otherwise, we have a default/namespace import that can be imported by any name, and
126906
126907
  // `symbolTableKey` will be something undesirable like `export=` or `default`, so we try to
126907
126908
  // get a better name.
126908
- var importedName = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126909
+ var names = exportKind === 0 /* Named */ || ts.isExternalModuleSymbol(namedSymbol)
126909
126910
  ? ts.unescapeLeadingUnderscores(symbolTableKey)
126910
- : ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
126911
+ : ts.getNamesForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined);
126912
+ var symbolName = typeof names === "string" ? names : names[0];
126913
+ var capitalizedSymbolName = typeof names === "string" ? undefined : names[1];
126911
126914
  var moduleName = ts.stripQuotes(moduleSymbol.name);
126912
126915
  var id = exportInfoId++;
126913
126916
  var target = ts.skipAlias(symbol, checker);
@@ -126915,17 +126918,18 @@ var ts;
126915
126918
  var storedModuleSymbol = moduleSymbol.flags & 33554432 /* Transient */ ? undefined : moduleSymbol;
126916
126919
  if (!storedSymbol || !storedModuleSymbol)
126917
126920
  symbols.set(id, [symbol, moduleSymbol]);
126918
- exportInfo.add(key(importedName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
126921
+ exportInfo.add(key(symbolName, symbol, ts.isExternalModuleNameRelative(moduleName) ? undefined : moduleName, checker), {
126919
126922
  id: id,
126920
126923
  symbolTableKey: symbolTableKey,
126921
- symbolName: importedName,
126924
+ symbolName: symbolName,
126925
+ capitalizedSymbolName: capitalizedSymbolName,
126922
126926
  moduleName: moduleName,
126923
126927
  moduleFile: moduleFile,
126924
126928
  moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName,
126925
126929
  packageName: packageName,
126926
126930
  exportKind: exportKind,
126927
126931
  targetFlags: target.flags,
126928
- source: source,
126932
+ isFromPackageJson: isFromPackageJson,
126929
126933
  symbol: storedSymbol,
126930
126934
  moduleSymbol: storedModuleSymbol,
126931
126935
  });
@@ -126936,21 +126940,18 @@ var ts;
126936
126940
  var result = exportInfo.get(key);
126937
126941
  return result === null || result === void 0 ? void 0 : result.map(rehydrateCachedInfo);
126938
126942
  },
126939
- forEach: function (importingFile, action) {
126943
+ search: function (importingFile, preferCapitalized, matches, action) {
126940
126944
  if (importingFile !== usableByFileName)
126941
126945
  return;
126942
126946
  exportInfo.forEach(function (info, key) {
126943
126947
  var _a = parseKey(key), symbolName = _a.symbolName, ambientModuleName = _a.ambientModuleName;
126944
- var rehydrated = info.map(rehydrateCachedInfo);
126945
- var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126946
- if (filtered.length) {
126947
- action(filtered, function (preferCapitalized) {
126948
- var _a = rehydrated[0], symbol = _a.symbol, exportKind = _a.exportKind;
126949
- var namedSymbol = exportKind === 1 /* Default */ && ts.getLocalSymbolForExportDefault(symbol) || symbol;
126950
- return preferCapitalized
126951
- ? ts.getNameForExportedSymbol(namedSymbol, /*scriptTarget*/ undefined, /*preferCapitalized*/ true)
126952
- : symbolName;
126953
- }, !!ambientModuleName, key);
126948
+ var name = preferCapitalized && info[0].capitalizedSymbolName || symbolName;
126949
+ if (matches(name, info[0].targetFlags)) {
126950
+ var rehydrated = info.map(rehydrateCachedInfo);
126951
+ var filtered = rehydrated.filter(function (r, i) { return isNotShadowedByDeeperNodeModulesPackage(r, info[i].packageName); });
126952
+ if (filtered.length) {
126953
+ action(filtered, name, !!ambientModuleName, key);
126954
+ }
126954
126955
  }
126955
126956
  });
126956
126957
  },
@@ -126985,7 +126986,7 @@ var ts;
126985
126986
  function rehydrateCachedInfo(info) {
126986
126987
  if (info.symbol && info.moduleSymbol)
126987
126988
  return info;
126988
- var id = info.id, exportKind = info.exportKind, targetFlags = info.targetFlags, source = info.source, moduleFileName = info.moduleFileName;
126989
+ var id = info.id, exportKind = info.exportKind, targetFlags = info.targetFlags, isFromPackageJson = info.isFromPackageJson, moduleFileName = info.moduleFileName;
126989
126990
  var _a = symbols.get(id) || ts.emptyArray, cachedSymbol = _a[0], cachedModuleSymbol = _a[1];
126990
126991
  if (cachedSymbol && cachedModuleSymbol) {
126991
126992
  return {
@@ -126994,10 +126995,12 @@ var ts;
126994
126995
  moduleFileName: moduleFileName,
126995
126996
  exportKind: exportKind,
126996
126997
  targetFlags: targetFlags,
126997
- source: source,
126998
+ isFromPackageJson: isFromPackageJson,
126998
126999
  };
126999
127000
  }
127000
- var checker = ts.getProgramForAutoImport(source, host.getCurrentProgram(), host).getTypeChecker();
127001
+ var checker = (isFromPackageJson
127002
+ ? host.getPackageJsonAutoImportProvider()
127003
+ : host.getCurrentProgram()).getTypeChecker();
127001
127004
  var moduleSymbol = info.moduleSymbol || cachedModuleSymbol || ts.Debug.checkDefined(info.moduleFile
127002
127005
  ? checker.getMergedSymbol(info.moduleFile.symbol)
127003
127006
  : checker.tryFindAmbientModule(info.moduleName));
@@ -127011,7 +127014,7 @@ var ts;
127011
127014
  moduleFileName: moduleFileName,
127012
127015
  exportKind: exportKind,
127013
127016
  targetFlags: targetFlags,
127014
- source: source,
127017
+ isFromPackageJson: isFromPackageJson,
127015
127018
  };
127016
127019
  }
127017
127020
  function key(importedName, symbol, ambientModuleName, checker) {
@@ -127095,48 +127098,15 @@ var ts;
127095
127098
  || ts.startsWith(getCanonicalFileName(fromPath), toNodeModulesParent)
127096
127099
  || (!!globalCachePath && ts.startsWith(getCanonicalFileName(globalCachePath), toNodeModulesParent));
127097
127100
  }
127098
- function forEachExternalModuleToImportFrom(program, host, preferences, cb) {
127101
+ function forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, cb) {
127099
127102
  var _a, _b;
127100
- var _c = ts.getAutoImportPreferences(preferences), includePackageJson = _c.includePackageJson, includeProjectReferences = _c.includeProjectReferences;
127101
- var resolvedReferencedProjects = includeProjectReferences && host.getProgramForReferencedProject
127102
- ? ts.compact(program.getResolvedProjectReferences() || ts.emptyArray)
127103
- : undefined;
127104
- var seenModules = ts.some(resolvedReferencedProjects) ? new ts.Set() : undefined;
127105
- forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) {
127106
- seenModules === null || seenModules === void 0 ? void 0 : seenModules.add((file === null || file === void 0 ? void 0 : file.path) || module.name);
127107
- cb(module, file, program, 1 /* Program */);
127108
- });
127109
- var autoImportProvider = includePackageJson && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host));
127103
+ forEachExternalModule(program.getTypeChecker(), program.getSourceFiles(), function (module, file) { return cb(module, file, program, /*isFromPackageJson*/ false); });
127104
+ var autoImportProvider = useAutoImportProvider && ((_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host));
127110
127105
  if (autoImportProvider) {
127111
127106
  var start = ts.timestamp();
127112
- forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) {
127113
- // The only reason we have to add files from package.json auto imports to the dedupe
127114
- // set for project references is that a referenced project symlinked through node_modules
127115
- // can show up here. We could add files only if their path does not contain '/node_modules/';
127116
- // I'm not sure whether that would be faster or slower, but probably doesn't make a big difference.
127117
- seenModules === null || seenModules === void 0 ? void 0 : seenModules.add((file === null || file === void 0 ? void 0 : file.path) || module.name);
127118
- cb(module, file, autoImportProvider, 2 /* PackageJson */);
127119
- });
127107
+ forEachExternalModule(autoImportProvider.getTypeChecker(), autoImportProvider.getSourceFiles(), function (module, file) { return cb(module, file, autoImportProvider, /*isFromPackageJson*/ true); });
127120
127108
  (_b = host.log) === null || _b === void 0 ? void 0 : _b.call(host, "forEachExternalModuleToImportFrom autoImportProvider: " + (ts.timestamp() - start));
127121
127109
  }
127122
- if (resolvedReferencedProjects) {
127123
- var _loop_3 = function (ref) {
127124
- var referencedProgram = host.getProgramForReferencedProject(ref.sourceFile.fileName);
127125
- if (referencedProgram) {
127126
- forEachExternalModule(referencedProgram.getTypeChecker(), ts.mapDefined(referencedProgram.getRootFileNames(), function (fileName) {
127127
- var file = referencedProgram.getSourceFile(fileName);
127128
- return file && !seenModules.has(file.path) ? file : undefined;
127129
- }), function (module, file) {
127130
- cb(module, file, referencedProgram, ref.sourceFile.fileName);
127131
- seenModules.add((file === null || file === void 0 ? void 0 : file.path) || module.name);
127132
- });
127133
- }
127134
- };
127135
- for (var _i = 0, resolvedReferencedProjects_1 = resolvedReferencedProjects; _i < resolvedReferencedProjects_1.length; _i++) {
127136
- var ref = resolvedReferencedProjects_1[_i];
127137
- _loop_3(ref);
127138
- }
127139
- }
127140
127110
  }
127141
127111
  ts.forEachExternalModuleToImportFrom = forEachExternalModuleToImportFrom;
127142
127112
  function forEachExternalModule(checker, allSourceFiles, cb) {
@@ -127153,7 +127123,7 @@ var ts;
127153
127123
  }
127154
127124
  }
127155
127125
  }
127156
- function getExportInfoMap(importingFile, host, program, cancellationToken, preferences) {
127126
+ function getExportInfoMap(importingFile, host, program, cancellationToken) {
127157
127127
  var _a, _b, _c, _d, _e;
127158
127128
  var start = ts.timestamp();
127159
127129
  // Pulling the AutoImportProvider project will trigger its updateGraph if pending,
@@ -127163,7 +127133,6 @@ var ts;
127163
127133
  var cache = ((_b = host.getCachedExportInfoMap) === null || _b === void 0 ? void 0 : _b.call(host)) || createCacheableExportInfoMap({
127164
127134
  getCurrentProgram: function () { return program; },
127165
127135
  getPackageJsonAutoImportProvider: function () { var _a; return (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host); },
127166
- getProgramForReferencedProject: function (configFileName) { var _a; return (_a = host.getProgramForReferencedProject) === null || _a === void 0 ? void 0 : _a.call(host, configFileName); },
127167
127136
  });
127168
127137
  if (cache.isUsableByFile(importingFile.path)) {
127169
127138
  (_c = host.log) === null || _c === void 0 ? void 0 : _c.call(host, "getExportInfoMap: cache hit");
@@ -127172,7 +127141,7 @@ var ts;
127172
127141
  (_d = host.log) === null || _d === void 0 ? void 0 : _d.call(host, "getExportInfoMap: cache miss or empty; calculating new results");
127173
127142
  var compilerOptions = program.getCompilerOptions();
127174
127143
  var moduleCount = 0;
127175
- forEachExternalModuleToImportFrom(program, host, preferences, function (moduleSymbol, moduleFile, program, source) {
127144
+ forEachExternalModuleToImportFrom(program, host, /*useAutoImportProvider*/ true, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
127176
127145
  if (++moduleCount % 100 === 0)
127177
127146
  cancellationToken === null || cancellationToken === void 0 ? void 0 : cancellationToken.throwIfCancellationRequested();
127178
127147
  var seenExports = new ts.Map();
@@ -127181,11 +127150,11 @@ var ts;
127181
127150
  // Note: I think we shouldn't actually see resolved module symbols here, but weird merges
127182
127151
  // can cause it to happen: see 'completionsImport_mergedReExport.ts'
127183
127152
  if (defaultInfo && isImportableSymbol(defaultInfo.symbol, checker)) {
127184
- cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, source, checker);
127153
+ cache.add(importingFile.path, defaultInfo.symbol, defaultInfo.exportKind === 1 /* Default */ ? "default" /* Default */ : "export=" /* ExportEquals */, moduleSymbol, moduleFile, defaultInfo.exportKind, isFromPackageJson, checker);
127185
127154
  }
127186
127155
  checker.forEachExportAndPropertyOfModule(moduleSymbol, function (exported, key) {
127187
127156
  if (exported !== (defaultInfo === null || defaultInfo === void 0 ? void 0 : defaultInfo.symbol) && isImportableSymbol(exported, checker) && ts.addToSeen(seenExports, key)) {
127188
- cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, source, checker);
127157
+ cache.add(importingFile.path, exported, key, moduleSymbol, moduleFile, 0 /* Named */, isFromPackageJson, checker);
127189
127158
  }
127190
127159
  });
127191
127160
  });
@@ -128930,7 +128899,7 @@ var ts;
128930
128899
  continue;
128931
128900
  var patterns = paths[path];
128932
128901
  if (patterns) {
128933
- var _loop_4 = function (name, kind, extension) {
128902
+ var _loop_3 = function (name, kind, extension) {
128934
128903
  // Path mappings may provide a duplicate way to get to something we've already added, so don't add again.
128935
128904
  if (!result.some(function (entry) { return entry.name === name; })) {
128936
128905
  result.push(nameAndKind(name, kind, extension));
@@ -128938,7 +128907,7 @@ var ts;
128938
128907
  };
128939
128908
  for (var _i = 0, _a = getCompletionsForPathMapping(path, patterns, fragment, baseDirectory, fileExtensions, host); _i < _a.length; _i++) {
128940
128909
  var _b = _a[_i], name = _b.name, kind = _b.kind, extension = _b.extension;
128941
- _loop_4(name, kind, extension);
128910
+ _loop_3(name, kind, extension);
128942
128911
  }
128943
128912
  }
128944
128913
  }
@@ -128973,7 +128942,7 @@ var ts;
128973
128942
  // (But do if we didn't find anything, e.g. 'package.json' missing.)
128974
128943
  var foundGlobal = false;
128975
128944
  if (fragmentDirectory === undefined) {
128976
- var _loop_5 = function (moduleName) {
128945
+ var _loop_4 = function (moduleName) {
128977
128946
  if (!result.some(function (entry) { return entry.name === moduleName; })) {
128978
128947
  foundGlobal = true;
128979
128948
  result.push(nameAndKind(moduleName, "external module name" /* externalModuleName */, /*extension*/ undefined));
@@ -128981,7 +128950,7 @@ var ts;
128981
128950
  };
128982
128951
  for (var _b = 0, _c = enumerateNodeModulesVisibleToScript(host, scriptPath); _b < _c.length; _b++) {
128983
128952
  var moduleName = _c[_b];
128984
- _loop_5(moduleName);
128953
+ _loop_4(moduleName);
128985
128954
  }
128986
128955
  }
128987
128956
  if (!foundGlobal) {
@@ -129290,7 +129259,7 @@ var ts;
129290
129259
  return originIsExport(origin) || originIsResolvedExport(origin);
129291
129260
  }
129292
129261
  function originIsPackageJsonImport(origin) {
129293
- return (originIsExport(origin) || originIsResolvedExport(origin)) && origin.source === 2 /* PackageJson */;
129262
+ return (originIsExport(origin) || originIsResolvedExport(origin)) && !!origin.isFromPackageJson;
129294
129263
  }
129295
129264
  function originIsPromise(origin) {
129296
129265
  return !!(origin.kind & 8 /* Promise */);
@@ -129450,7 +129419,7 @@ var ts;
129450
129419
  if (!previousResponse)
129451
129420
  return undefined;
129452
129421
  var lowerCaseTokenText = location.text.toLowerCase();
129453
- var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken, preferences);
129422
+ var exportMap = ts.getExportInfoMap(file, host, program, cancellationToken);
129454
129423
  var newEntries = resolvingModuleSpecifiers("continuePreviousIncompleteResponse", host, program, file, preferences,
129455
129424
  /*isForImportStatementCompletion*/ false, function (context) {
129456
129425
  var entries = ts.mapDefined(previousResponse.entries, function (entry) {
@@ -129969,13 +129938,14 @@ var ts;
129969
129938
  }
129970
129939
  function originToCompletionEntryData(origin) {
129971
129940
  var ambientModuleName = origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name);
129941
+ var isPackageJsonImport = origin.isFromPackageJson ? true : undefined;
129972
129942
  if (originIsResolvedExport(origin)) {
129973
129943
  var resolvedData = {
129974
129944
  exportName: origin.exportName,
129975
129945
  moduleSpecifier: origin.moduleSpecifier,
129976
129946
  ambientModuleName: ambientModuleName,
129977
129947
  fileName: origin.fileName,
129978
- source: origin.source,
129948
+ isPackageJsonImport: isPackageJsonImport,
129979
129949
  };
129980
129950
  return resolvedData;
129981
129951
  }
@@ -129984,12 +129954,13 @@ var ts;
129984
129954
  exportMapKey: origin.exportMapKey,
129985
129955
  fileName: origin.fileName,
129986
129956
  ambientModuleName: origin.fileName ? undefined : ts.stripQuotes(origin.moduleSymbol.name),
129987
- source: origin.source,
129957
+ isPackageJsonImport: origin.isFromPackageJson ? true : undefined,
129988
129958
  };
129989
129959
  return unresolvedData;
129990
129960
  }
129991
129961
  function completionEntryDataToSymbolOriginInfo(data, completionName, moduleSymbol) {
129992
129962
  var isDefaultExport = data.exportName === "default" /* Default */;
129963
+ var isFromPackageJson = !!data.isPackageJsonImport;
129993
129964
  if (completionEntryDataIsResolved(data)) {
129994
129965
  var resolvedOrigin = {
129995
129966
  kind: 32 /* ResolvedExport */,
@@ -129997,9 +129968,9 @@ var ts;
129997
129968
  moduleSpecifier: data.moduleSpecifier,
129998
129969
  symbolName: completionName,
129999
129970
  fileName: data.fileName,
130000
- source: data.source,
130001
129971
  moduleSymbol: moduleSymbol,
130002
129972
  isDefaultExport: isDefaultExport,
129973
+ isFromPackageJson: isFromPackageJson,
130003
129974
  };
130004
129975
  return resolvedOrigin;
130005
129976
  }
@@ -130009,9 +129980,9 @@ var ts;
130009
129980
  exportMapKey: data.exportMapKey,
130010
129981
  symbolName: completionName,
130011
129982
  fileName: data.fileName,
130012
- source: data.source,
130013
129983
  moduleSymbol: moduleSymbol,
130014
129984
  isDefaultExport: isDefaultExport,
129985
+ isFromPackageJson: isFromPackageJson,
130015
129986
  };
130016
129987
  return unresolvedOrigin;
130017
129988
  }
@@ -130297,7 +130268,7 @@ var ts;
130297
130268
  if (!origin || !(originIsExport(origin) || originIsResolvedExport(origin))) {
130298
130269
  return { codeActions: undefined, sourceDisplay: undefined };
130299
130270
  }
130300
- var checker = ts.getProgramForAutoImport(origin.source, program, host).getTypeChecker();
130271
+ var checker = origin.isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker();
130301
130272
  var moduleSymbol = origin.moduleSymbol;
130302
130273
  var targetSymbol = checker.getMergedSymbol(ts.skipAlias(symbol.exportSymbol || symbol, checker));
130303
130274
  var isJsxOpeningTagName = (contextToken === null || contextToken === void 0 ? void 0 : contextToken.kind) === 29 /* LessThanToken */ && ts.isJsxOpeningLikeElement(contextToken.parent);
@@ -130626,8 +130597,8 @@ var ts;
130626
130597
  var symbolToSortTextIdMap = [];
130627
130598
  var seenPropertySymbols = new ts.Map();
130628
130599
  var isTypeOnlyLocation = isTypeOnlyCompletion();
130629
- var getModuleSpecifierResolutionHost = ts.memoizeOne(function (source) {
130630
- return ts.createModuleSpecifierResolutionHost(ts.getProgramForAutoImport(source, program, host), host);
130600
+ var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
130601
+ return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
130631
130602
  });
130632
130603
  if (isRightOfDot || isRightOfQuestionDot) {
130633
130604
  getTypeScriptMemberSymbols();
@@ -130836,7 +130807,7 @@ var ts;
130836
130807
  var moduleSpecifier = (ts.codefix.getModuleSpecifierForBestExportInfo([{
130837
130808
  exportKind: 0 /* Named */,
130838
130809
  moduleFileName: fileName,
130839
- source: 1 /* Program */,
130810
+ isFromPackageJson: false,
130840
130811
  moduleSymbol: moduleSymbol,
130841
130812
  symbol: firstAccessibleSymbol,
130842
130813
  targetFlags: ts.skipAlias(firstAccessibleSymbol, typeChecker).flags,
@@ -130848,7 +130819,6 @@ var ts;
130848
130819
  isDefaultExport: false,
130849
130820
  symbolName: firstAccessibleSymbol.name,
130850
130821
  exportName: firstAccessibleSymbol.name,
130851
- source: 1 /* Program */,
130852
130822
  fileName: fileName,
130853
130823
  moduleSpecifier: moduleSpecifier,
130854
130824
  };
@@ -131077,7 +131047,7 @@ var ts;
131077
131047
  }
131078
131048
  /** Mutates `symbols`, `symbolToOriginInfoMap`, and `symbolToSortTextIdMap` */
131079
131049
  function collectAutoImports() {
131080
- var _a;
131050
+ var _a, _b;
131081
131051
  if (!shouldOfferImportCompletions())
131082
131052
  return;
131083
131053
  ts.Debug.assert(!(detailsEntryId === null || detailsEntryId === void 0 ? void 0 : detailsEntryId.data), "Should not run 'collectAutoImports' when faster path is available via `data`");
@@ -131093,48 +131063,51 @@ var ts;
131093
131063
  previousToken && ts.isIdentifier(previousToken) ? previousToken.text.toLowerCase() :
131094
131064
  "";
131095
131065
  var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
131096
- var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken, preferences);
131097
- var getProgramForAutoImport = ts.createMemoizedGetProgramForAutoImport(program, host);
131066
+ var exportInfo = ts.getExportInfoMap(sourceFile, host, program, cancellationToken);
131067
+ var packageJsonAutoImportProvider = (_b = host.getPackageJsonAutoImportProvider) === null || _b === void 0 ? void 0 : _b.call(host);
131098
131068
  var packageJsonFilter = detailsEntryId ? undefined : ts.createPackageJsonImportFilter(sourceFile, preferences, host);
131099
131069
  resolvingModuleSpecifiers("collectAutoImports", host, program, sourceFile, preferences, !!importCompletionNode, function (context) {
131100
- exportInfo.forEach(sourceFile.path, function (info, getSymbolName, isFromAmbientModule, exportMapKey) {
131101
- var symbolName = getSymbolName(/*preferCapitalized*/ isRightOfOpenTag);
131070
+ exportInfo.search(sourceFile.path,
131071
+ /*preferCapitalized*/ isRightOfOpenTag, function (symbolName, targetFlags) {
131102
131072
  if (!ts.isIdentifierText(symbolName, ts.getEmitScriptTarget(host.getCompilationSettings())))
131103
- return;
131073
+ return false;
131104
131074
  if (!detailsEntryId && ts.isStringANonContextualKeyword(symbolName))
131105
- return;
131106
- // `targetFlags` should be the same for each `info`
131107
- if (!isTypeOnlyLocation && !importCompletionNode && !(info[0].targetFlags & 111551 /* Value */))
131108
- return;
131109
- if (isTypeOnlyLocation && !(info[0].targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131110
- return;
131075
+ return false;
131076
+ if (!isTypeOnlyLocation && !importCompletionNode && !(targetFlags & 111551 /* Value */))
131077
+ return false;
131078
+ if (isTypeOnlyLocation && !(targetFlags & (1536 /* Module */ | 788968 /* Type */)))
131079
+ return false;
131111
131080
  // Do not try to auto-import something with a lowercase first letter for a JSX tag
131112
131081
  var firstChar = symbolName.charCodeAt(0);
131113
131082
  if (isRightOfOpenTag && (firstChar < 65 /* A */ || firstChar > 90 /* Z */))
131083
+ return false;
131084
+ if (detailsEntryId)
131085
+ return true;
131086
+ return charactersFuzzyMatchInString(symbolName, lowerCaseTokenText);
131087
+ }, function (info, symbolName, isFromAmbientModule, exportMapKey) {
131088
+ if (detailsEntryId && !ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); })) {
131089
+ return;
131090
+ }
131091
+ var defaultExportInfo = ts.find(info, isImportableExportInfo);
131092
+ if (!defaultExportInfo) {
131114
131093
  return;
131115
- var isCompletionDetailsMatch = detailsEntryId && ts.some(info, function (i) { return detailsEntryId.source === ts.stripQuotes(i.moduleSymbol.name); });
131116
- if (isCompletionDetailsMatch || !detailsEntryId && charactersFuzzyMatchInString(symbolName, lowerCaseTokenText)) {
131117
- var defaultExportInfo = ts.find(info, isImportableExportInfo);
131118
- if (!defaultExportInfo) {
131119
- return;
131120
- }
131121
- // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131122
- // (We need to ensure that at least one is importable to show a completion.)
131123
- var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo_1 = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131124
- var isDefaultExport = exportInfo_1.exportKind === 1 /* Default */;
131125
- var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo_1.symbol) || exportInfo_1.symbol;
131126
- pushAutoImportSymbol(symbol, {
131127
- kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131128
- moduleSpecifier: moduleSpecifier,
131129
- symbolName: symbolName,
131130
- exportMapKey: exportMapKey,
131131
- exportName: exportInfo_1.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo_1.symbol.name,
131132
- fileName: exportInfo_1.moduleFileName,
131133
- isDefaultExport: isDefaultExport,
131134
- moduleSymbol: exportInfo_1.moduleSymbol,
131135
- source: exportInfo_1.source,
131136
- });
131137
131094
  }
131095
+ // If we don't need to resolve module specifiers, we can use any re-export that is importable at all
131096
+ // (We need to ensure that at least one is importable to show a completion.)
131097
+ var _a = context.tryResolve(info, isFromAmbientModule) || {}, _b = _a.exportInfo, exportInfo = _b === void 0 ? defaultExportInfo : _b, moduleSpecifier = _a.moduleSpecifier;
131098
+ var isDefaultExport = exportInfo.exportKind === 1 /* Default */;
131099
+ var symbol = isDefaultExport && ts.getLocalSymbolForExportDefault(exportInfo.symbol) || exportInfo.symbol;
131100
+ pushAutoImportSymbol(symbol, {
131101
+ kind: moduleSpecifier ? 32 /* ResolvedExport */ : 4 /* Export */,
131102
+ moduleSpecifier: moduleSpecifier,
131103
+ symbolName: symbolName,
131104
+ exportMapKey: exportMapKey,
131105
+ exportName: exportInfo.exportKind === 2 /* ExportEquals */ ? "export=" /* ExportEquals */ : exportInfo.symbol.name,
131106
+ fileName: exportInfo.moduleFileName,
131107
+ isDefaultExport: isDefaultExport,
131108
+ moduleSymbol: exportInfo.moduleSymbol,
131109
+ isFromPackageJson: exportInfo.isFromPackageJson,
131110
+ });
131138
131111
  });
131139
131112
  hasUnresolvedAutoImports = context.resolutionLimitExceeded();
131140
131113
  });
@@ -131146,10 +131119,10 @@ var ts;
131146
131119
  return false;
131147
131120
  }
131148
131121
  return packageJsonFilter
131149
- ? packageJsonFilter.allowsImportingAmbientModule(info.moduleSymbol, getModuleSpecifierResolutionHost(info.source))
131122
+ ? packageJsonFilter.allowsImportingAmbientModule(info.moduleSymbol, getModuleSpecifierResolutionHost(info.isFromPackageJson))
131150
131123
  : true;
131151
131124
  }
131152
- return ts.isImportableFile(getProgramForAutoImport(info.source), sourceFile, moduleFile, preferences, packageJsonFilter, getModuleSpecifierResolutionHost(info.source), moduleSpecifierCache);
131125
+ return ts.isImportableFile(info.isFromPackageJson ? packageJsonAutoImportProvider : program, sourceFile, moduleFile, preferences, packageJsonFilter, getModuleSpecifierResolutionHost(info.isFromPackageJson), moduleSpecifierCache);
131153
131126
  }
131154
131127
  }
131155
131128
  function pushAutoImportSymbol(symbol, origin) {
@@ -131945,7 +131918,7 @@ var ts;
131945
131918
  return { contextToken: previousToken, previousToken: previousToken };
131946
131919
  }
131947
131920
  function getAutoImportSymbolFromCompletionEntryData(name, data, program, host) {
131948
- var containingProgram = ts.getProgramForAutoImport(data.source, program, host);
131921
+ var containingProgram = data.isPackageJsonImport ? host.getPackageJsonAutoImportProvider() : program;
131949
131922
  var checker = containingProgram.getTypeChecker();
131950
131923
  var moduleSymbol = data.ambientModuleName ? checker.tryFindAmbientModule(data.ambientModuleName) :
131951
131924
  data.fileName ? checker.getMergedSymbol(ts.Debug.checkDefined(containingProgram.getSourceFile(data.fileName)).symbol) :
@@ -134376,7 +134349,7 @@ var ts;
134376
134349
  result = references;
134377
134350
  continue;
134378
134351
  }
134379
- var _loop_6 = function (entry) {
134352
+ var _loop_5 = function (entry) {
134380
134353
  if (!entry.definition || entry.definition.type !== 0 /* Symbol */) {
134381
134354
  result.push(entry);
134382
134355
  return "continue";
@@ -134408,7 +134381,7 @@ var ts;
134408
134381
  };
134409
134382
  for (var _b = 0, references_2 = references; _b < references_2.length; _b++) {
134410
134383
  var entry = references_2[_b];
134411
- _loop_6(entry);
134384
+ _loop_5(entry);
134412
134385
  }
134413
134386
  }
134414
134387
  return result;
@@ -136387,7 +136360,7 @@ var ts;
136387
136360
  }
136388
136361
  function updateImports(program, changeTracker, oldToNew, newToOld, host, getCanonicalFileName) {
136389
136362
  var allFiles = program.getSourceFiles();
136390
- var _loop_7 = function (sourceFile) {
136363
+ var _loop_6 = function (sourceFile) {
136391
136364
  var newFromOld = oldToNew(sourceFile.fileName);
136392
136365
  var newImportFromPath = newFromOld !== null && newFromOld !== void 0 ? newFromOld : sourceFile.fileName;
136393
136366
  var newImportFromDirectory = ts.getDirectoryPath(newImportFromPath);
@@ -136419,7 +136392,7 @@ var ts;
136419
136392
  };
136420
136393
  for (var _i = 0, allFiles_1 = allFiles; _i < allFiles_1.length; _i++) {
136421
136394
  var sourceFile = allFiles_1[_i];
136422
- _loop_7(sourceFile);
136395
+ _loop_6(sourceFile);
136423
136396
  }
136424
136397
  }
136425
136398
  function combineNormal(pathA, pathB) {
@@ -137359,7 +137332,7 @@ var ts;
137359
137332
  if (!patternMatcher)
137360
137333
  return ts.emptyArray;
137361
137334
  var rawItems = [];
137362
- var _loop_8 = function (sourceFile) {
137335
+ var _loop_7 = function (sourceFile) {
137363
137336
  cancellationToken.throwIfCancellationRequested();
137364
137337
  if (excludeDtsFiles && sourceFile.isDeclarationFile) {
137365
137338
  return "continue";
@@ -137371,7 +137344,7 @@ var ts;
137371
137344
  // Search the declarations in all files and output matched NavigateToItem into array of NavigateToItem[]
137372
137345
  for (var _i = 0, sourceFiles_4 = sourceFiles; _i < sourceFiles_4.length; _i++) {
137373
137346
  var sourceFile = sourceFiles_4[_i];
137374
- _loop_8(sourceFile);
137347
+ _loop_7(sourceFile);
137375
137348
  }
137376
137349
  rawItems.sort(compareNavigateToItems);
137377
137350
  return (maxResultCount === undefined ? rawItems : rawItems.slice(0, maxResultCount)).map(createNavigateToItem);
@@ -139393,13 +139366,13 @@ var ts;
139393
139366
  // Assumes 'value' is already lowercase.
139394
139367
  function indexOfIgnoringCase(str, value) {
139395
139368
  var n = str.length - value.length;
139396
- var _loop_9 = function (start) {
139369
+ var _loop_8 = function (start) {
139397
139370
  if (every(value, function (valueChar, i) { return toLowerCase(str.charCodeAt(i + start)) === valueChar; })) {
139398
139371
  return { value: start };
139399
139372
  }
139400
139373
  };
139401
139374
  for (var start = 0; start <= n; start++) {
139402
- var state_3 = _loop_9(start);
139375
+ var state_3 = _loop_8(start);
139403
139376
  if (typeof state_3 === "object")
139404
139377
  return state_3.value;
139405
139378
  }
@@ -140499,12 +140472,12 @@ var ts;
140499
140472
  : { invocation: info.invocation.node, argumentCount: info.argumentCount, argumentIndex: info.argumentIndex };
140500
140473
  }
140501
140474
  SignatureHelp.getArgumentInfoForCompletions = getArgumentInfoForCompletions;
140502
- function getArgumentOrParameterListInfo(node, sourceFile) {
140475
+ function getArgumentOrParameterListInfo(node, position, sourceFile) {
140503
140476
  var info = getArgumentOrParameterListAndIndex(node, sourceFile);
140504
140477
  if (!info)
140505
140478
  return undefined;
140506
140479
  var list = info.list, argumentIndex = info.argumentIndex;
140507
- var argumentCount = getArgumentCount(list);
140480
+ var argumentCount = getArgumentCount(list, /*ignoreTrailingComma*/ ts.isInString(sourceFile, position, node));
140508
140481
  if (argumentIndex !== 0) {
140509
140482
  ts.Debug.assertLessThan(argumentIndex, argumentCount);
140510
140483
  }
@@ -140550,7 +140523,7 @@ var ts;
140550
140523
  // Case 3:
140551
140524
  // foo<T#, U#>(a#, #b#) -> The token is buried inside a list, and should give signature help
140552
140525
  // Find out if 'node' is an argument, a type argument, or neither
140553
- var info = getArgumentOrParameterListInfo(node, sourceFile);
140526
+ var info = getArgumentOrParameterListInfo(node, position, sourceFile);
140554
140527
  if (!info)
140555
140528
  return undefined;
140556
140529
  var list = info.list, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140619,8 +140592,8 @@ var ts;
140619
140592
  function countBinaryExpressionParameters(b) {
140620
140593
  return ts.isBinaryExpression(b.left) ? countBinaryExpressionParameters(b.left) + 1 : 2;
140621
140594
  }
140622
- function tryGetParameterInfo(startingToken, _position, sourceFile, checker) {
140623
- var info = getContextualSignatureLocationInfo(startingToken, sourceFile, checker);
140595
+ function tryGetParameterInfo(startingToken, position, sourceFile, checker) {
140596
+ var info = getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker);
140624
140597
  if (!info)
140625
140598
  return undefined;
140626
140599
  var contextualType = info.contextualType, argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140632,7 +140605,7 @@ var ts;
140632
140605
  var invocation = { kind: 2 /* Contextual */, signature: ts.first(signatures), node: startingToken, symbol: chooseBetterSymbol(nonNullableContextualType.symbol) };
140633
140606
  return { isTypeParameterList: false, invocation: invocation, argumentsSpan: argumentsSpan, argumentIndex: argumentIndex, argumentCount: argumentCount };
140634
140607
  }
140635
- function getContextualSignatureLocationInfo(startingToken, sourceFile, checker) {
140608
+ function getContextualSignatureLocationInfo(startingToken, sourceFile, position, checker) {
140636
140609
  if (startingToken.kind !== 20 /* OpenParenToken */ && startingToken.kind !== 27 /* CommaToken */)
140637
140610
  return undefined;
140638
140611
  var parent = startingToken.parent;
@@ -140641,7 +140614,7 @@ var ts;
140641
140614
  case 168 /* MethodDeclaration */:
140642
140615
  case 212 /* FunctionExpression */:
140643
140616
  case 213 /* ArrowFunction */:
140644
- var info = getArgumentOrParameterListInfo(startingToken, sourceFile);
140617
+ var info = getArgumentOrParameterListInfo(startingToken, position, sourceFile);
140645
140618
  if (!info)
140646
140619
  return undefined;
140647
140620
  var argumentIndex = info.argumentIndex, argumentCount = info.argumentCount, argumentsSpan = info.argumentsSpan;
@@ -140688,7 +140661,7 @@ var ts;
140688
140661
  }
140689
140662
  return argumentIndex;
140690
140663
  }
140691
- function getArgumentCount(argumentsList) {
140664
+ function getArgumentCount(argumentsList, ignoreTrailingComma) {
140692
140665
  // The argument count for a list is normally the number of non-comma children it has.
140693
140666
  // For example, if you have "Foo(a,b)" then there will be three children of the arg
140694
140667
  // list 'a' '<comma>' 'b'. So, in this case the arg count will be 2. However, there
@@ -140702,7 +140675,7 @@ var ts;
140702
140675
  // arg count of 3.
140703
140676
  var listChildren = argumentsList.getChildren();
140704
140677
  var argumentCount = ts.countWhere(listChildren, function (arg) { return arg.kind !== 27 /* CommaToken */; });
140705
- if (listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
140678
+ if (!ignoreTrailingComma && listChildren.length > 0 && ts.last(listChildren).kind === 27 /* CommaToken */) {
140706
140679
  argumentCount++;
140707
140680
  }
140708
140681
  return argumentCount;
@@ -140780,7 +140753,7 @@ var ts;
140780
140753
  return ts.createTextSpan(applicableSpanStart, applicableSpanEnd - applicableSpanStart);
140781
140754
  }
140782
140755
  function getContainingArgumentInfo(node, position, sourceFile, checker, isManuallyInvoked) {
140783
- var _loop_10 = function (n) {
140756
+ var _loop_9 = function (n) {
140784
140757
  // If the node is not a subspan of its parent, this is a big problem.
140785
140758
  // There have been crashes that might be caused by this violation.
140786
140759
  ts.Debug.assert(ts.rangeContainsRange(n.parent, n), "Not a subspan", function () { return "Child: " + ts.Debug.formatSyntaxKind(n.kind) + ", parent: " + ts.Debug.formatSyntaxKind(n.parent.kind); });
@@ -140790,7 +140763,7 @@ var ts;
140790
140763
  }
140791
140764
  };
140792
140765
  for (var n = node; !ts.isSourceFile(n) && (isManuallyInvoked || !ts.isBlock(n)); n = n.parent) {
140793
- var state_4 = _loop_10(n);
140766
+ var state_4 = _loop_9(n);
140794
140767
  if (typeof state_4 === "object")
140795
140768
  return state_4.value;
140796
140769
  }
@@ -142156,6 +142129,18 @@ var ts;
142156
142129
  }
142157
142130
  }
142158
142131
  }
142132
+ if (documentation.length === 0 && ts.isIdentifier(location) && symbol.valueDeclaration && ts.isBindingElement(symbol.valueDeclaration)) {
142133
+ var declaration = symbol.valueDeclaration;
142134
+ var parent = declaration.parent;
142135
+ if (ts.isIdentifier(declaration.name) && ts.isObjectBindingPattern(parent)) {
142136
+ var name_4 = ts.getTextOfIdentifierOrLiteral(declaration.name);
142137
+ var objectType = typeChecker.getTypeAtLocation(parent);
142138
+ documentation = ts.firstDefined(objectType.isUnion() ? objectType.types : [objectType], function (t) {
142139
+ var prop = t.getProperty(name_4);
142140
+ return prop ? prop.getDocumentationComment(typeChecker) : undefined;
142141
+ }) || ts.emptyArray;
142142
+ }
142143
+ }
142159
142144
  if (tags.length === 0 && !hasMultipleSignatures) {
142160
142145
  tags = symbol.getContextualJsDocTags(enclosingDeclaration, typeChecker);
142161
142146
  }
@@ -142373,7 +142358,7 @@ var ts;
142373
142358
  commandLineOptionsStringToEnum = commandLineOptionsStringToEnum ||
142374
142359
  ts.filter(ts.optionDeclarations, function (o) { return typeof o.type === "object" && !ts.forEachEntry(o.type, function (v) { return typeof v !== "number"; }); });
142375
142360
  options = ts.cloneCompilerOptions(options);
142376
- var _loop_11 = function (opt) {
142361
+ var _loop_10 = function (opt) {
142377
142362
  if (!ts.hasProperty(options, opt.name)) {
142378
142363
  return "continue";
142379
142364
  }
@@ -142392,7 +142377,7 @@ var ts;
142392
142377
  };
142393
142378
  for (var _i = 0, commandLineOptionsStringToEnum_1 = commandLineOptionsStringToEnum; _i < commandLineOptionsStringToEnum_1.length; _i++) {
142394
142379
  var opt = commandLineOptionsStringToEnum_1[_i];
142395
- _loop_11(opt);
142380
+ _loop_10(opt);
142396
142381
  }
142397
142382
  return options;
142398
142383
  }
@@ -146102,7 +146087,7 @@ var ts;
146102
146087
  ChangeTracker.prototype.finishDeleteDeclarations = function () {
146103
146088
  var _this = this;
146104
146089
  var deletedNodesInLists = new ts.Set(); // Stores nodes in lists that we already deleted. Used to avoid deleting `, ` twice in `a, b`.
146105
- var _loop_12 = function (sourceFile, node) {
146090
+ var _loop_11 = function (sourceFile, node) {
146106
146091
  if (!this_1.deletedNodes.some(function (d) { return d.sourceFile === sourceFile && ts.rangeContainsRangeExclusive(d.node, node); })) {
146107
146092
  if (ts.isArray(node)) {
146108
146093
  this_1.deleteRange(sourceFile, ts.rangeOfTypeParameters(sourceFile, node));
@@ -146115,7 +146100,7 @@ var ts;
146115
146100
  var this_1 = this;
146116
146101
  for (var _i = 0, _a = this.deletedNodes; _i < _a.length; _i++) {
146117
146102
  var _b = _a[_i], sourceFile = _b.sourceFile, node = _b.node;
146118
- _loop_12(sourceFile, node);
146103
+ _loop_11(sourceFile, node);
146119
146104
  }
146120
146105
  deletedNodesInLists.forEach(function (node) {
146121
146106
  var sourceFile = node.getSourceFile();
@@ -146203,14 +146188,14 @@ var ts;
146203
146188
  // order changes by start position
146204
146189
  // If the start position is the same, put the shorter range first, since an empty range (x, x) may precede (x, y) but not vice-versa.
146205
146190
  var normalized = ts.stableSort(changesInFile, function (a, b) { return (a.range.pos - b.range.pos) || (a.range.end - b.range.end); });
146206
- var _loop_13 = function (i) {
146191
+ var _loop_12 = function (i) {
146207
146192
  ts.Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos, "Changes overlap", function () {
146208
146193
  return JSON.stringify(normalized[i].range) + " and " + JSON.stringify(normalized[i + 1].range);
146209
146194
  });
146210
146195
  };
146211
146196
  // verify that change intervals do not overlap, except possibly at end points.
146212
146197
  for (var i = 0; i < normalized.length - 1; i++) {
146213
- _loop_13(i);
146198
+ _loop_12(i);
146214
146199
  }
146215
146200
  var textChanges = ts.mapDefined(normalized, function (c) {
146216
146201
  var span = ts.createTextSpanFromRange(c.range);
@@ -147116,7 +147101,7 @@ var ts;
147116
147101
  }
147117
147102
  var isCompleteFix = identifiers.isCompleteFix;
147118
147103
  var initializers;
147119
- var _loop_14 = function (identifier) {
147104
+ var _loop_13 = function (identifier) {
147120
147105
  var symbol = checker.getSymbolAtLocation(identifier);
147121
147106
  if (!symbol) {
147122
147107
  return "continue";
@@ -147149,7 +147134,7 @@ var ts;
147149
147134
  };
147150
147135
  for (var _i = 0, _a = identifiers.identifiers; _i < _a.length; _i++) {
147151
147136
  var identifier = _a[_i];
147152
- _loop_14(identifier);
147137
+ _loop_13(identifier);
147153
147138
  }
147154
147139
  return initializers && {
147155
147140
  initializers: initializers,
@@ -148030,7 +148015,7 @@ var ts;
148030
148015
  functionToConvert.getStart(sourceFile);
148031
148016
  var options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " };
148032
148017
  changes.insertModifierAt(sourceFile, pos, 131 /* AsyncKeyword */, options);
148033
- var _loop_15 = function (returnStatement) {
148018
+ var _loop_14 = function (returnStatement) {
148034
148019
  ts.forEachChild(returnStatement, function visit(node) {
148035
148020
  if (ts.isCallExpression(node)) {
148036
148021
  var newNodes = transformExpression(node, node, transformer, /*hasContinuation*/ false);
@@ -148052,7 +148037,7 @@ var ts;
148052
148037
  };
148053
148038
  for (var _i = 0, returnStatements_1 = returnStatements; _i < returnStatements_1.length; _i++) {
148054
148039
  var returnStatement = returnStatements_1[_i];
148055
- var state_5 = _loop_15(returnStatement);
148040
+ var state_5 = _loop_14(returnStatement);
148056
148041
  if (typeof state_5 === "object")
148057
148042
  return state_5.value;
148058
148043
  }
@@ -149499,7 +149484,7 @@ var ts;
149499
149484
  errorCodes: errorCodes,
149500
149485
  getCodeActions: function (context) {
149501
149486
  var errorCode = context.errorCode, preferences = context.preferences, sourceFile = context.sourceFile, span = context.span, program = context.program;
149502
- var info = getFixesInfo(context, errorCode, span.start);
149487
+ var info = getFixesInfo(context, errorCode, span.start, /*useAutoImportProvider*/ true);
149503
149488
  if (!info)
149504
149489
  return undefined;
149505
149490
  var fixes = info.fixes, symbolName = info.symbolName, errorIdentifierText = info.errorIdentifierText;
@@ -149510,16 +149495,16 @@ var ts;
149510
149495
  fixIds: [importFixId],
149511
149496
  getAllCodeActions: function (context) {
149512
149497
  var sourceFile = context.sourceFile, program = context.program, preferences = context.preferences, host = context.host;
149513
- var importAdder = createImportAdderWorker(sourceFile, program, preferences, host);
149498
+ var importAdder = createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ true, preferences, host);
149514
149499
  codefix.eachDiagnostic(context, errorCodes, function (diag) { return importAdder.addImportFromDiagnostic(diag, context); });
149515
149500
  return codefix.createCombinedCodeActions(ts.textChanges.ChangeTracker.with(context, importAdder.writeFixes));
149516
149501
  },
149517
149502
  });
149518
149503
  function createImportAdder(sourceFile, program, preferences, host) {
149519
- return createImportAdderWorker(sourceFile, program, preferences, host);
149504
+ return createImportAdderWorker(sourceFile, program, /*useAutoImportProvider*/ false, preferences, host);
149520
149505
  }
149521
149506
  codefix.createImportAdder = createImportAdder;
149522
- function createImportAdderWorker(sourceFile, program, preferences, host) {
149507
+ function createImportAdderWorker(sourceFile, program, useAutoImportProvider, preferences, host) {
149523
149508
  var compilerOptions = program.getCompilerOptions();
149524
149509
  // Namespace fixes don't conflict, so just build a list.
149525
149510
  var addToNamespace = [];
@@ -149530,7 +149515,7 @@ var ts;
149530
149515
  var newImports = new ts.Map();
149531
149516
  return { addImportFromDiagnostic: addImportFromDiagnostic, addImportFromExportedSymbol: addImportFromExportedSymbol, writeFixes: writeFixes, hasFixes: hasFixes };
149532
149517
  function addImportFromDiagnostic(diagnostic, context) {
149533
- var info = getFixesInfo(context, diagnostic.code, diagnostic.start);
149518
+ var info = getFixesInfo(context, diagnostic.code, diagnostic.start, useAutoImportProvider);
149534
149519
  if (!info || !info.fixes.length)
149535
149520
  return;
149536
149521
  addImport(info);
@@ -149540,10 +149525,7 @@ var ts;
149540
149525
  var symbolName = ts.getNameForExportedSymbol(exportedSymbol, ts.getEmitScriptTarget(compilerOptions));
149541
149526
  var checker = program.getTypeChecker();
149542
149527
  var symbol = checker.getMergedSymbol(ts.skipAlias(exportedSymbol, checker));
149543
- var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, __assign(__assign({}, preferences), {
149544
- // This function has already assumed that `exportedSymbol` is from the main program,
149545
- // so there's no need to go looking in other programs.
149546
- includePackageJsonAutoImports: "off", includeProjectReferenceAutoImports: "off" }));
149528
+ var exportInfos = getAllReExportingModules(sourceFile, symbol, moduleSymbol, symbolName, /*isJsxTagName*/ false, host, program, preferences, useAutoImportProvider);
149547
149529
  var useRequire = shouldUseRequire(sourceFile, program);
149548
149530
  var fix = getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, /*position*/ undefined, !!isValidTypeOnlyUseSite, useRequire, host, preferences);
149549
149531
  if (fix) {
@@ -149712,7 +149694,7 @@ var ts;
149712
149694
  var compilerOptions = program.getCompilerOptions();
149713
149695
  var exportInfos = ts.pathIsBareSpecifier(ts.stripQuotes(moduleSymbol.name))
149714
149696
  ? [getSymbolExportInfoForSymbol(targetSymbol, moduleSymbol, program, host)]
149715
- : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences);
149697
+ : getAllReExportingModules(sourceFile, targetSymbol, moduleSymbol, symbolName, isJsxTagName, host, program, preferences, /*useAutoImportProvider*/ true);
149716
149698
  var useRequire = shouldUseRequire(sourceFile, program);
149717
149699
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(ts.getTokenAtPosition(sourceFile, position));
149718
149700
  var fix = ts.Debug.checkDefined(getImportFixForSymbol(sourceFile, exportInfos, moduleSymbol, symbolName, program, position, isValidTypeOnlyUseSite, useRequire, host, preferences));
@@ -149743,50 +149725,50 @@ var ts;
149743
149725
  function getSymbolExportInfoForSymbol(symbol, moduleSymbol, program, host) {
149744
149726
  var _a, _b;
149745
149727
  var compilerOptions = program.getCompilerOptions();
149746
- var mainProgramInfo = getInfoWithChecker(program.getTypeChecker(), 1 /* Program */);
149728
+ var mainProgramInfo = getInfoWithChecker(program.getTypeChecker(), /*isFromPackageJson*/ false);
149747
149729
  if (mainProgramInfo) {
149748
149730
  return mainProgramInfo;
149749
149731
  }
149750
149732
  var autoImportProvider = (_b = (_a = host.getPackageJsonAutoImportProvider) === null || _a === void 0 ? void 0 : _a.call(host)) === null || _b === void 0 ? void 0 : _b.getTypeChecker();
149751
- return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider, 2 /* PackageJson */), "Could not find symbol in specified module for code actions");
149752
- function getInfoWithChecker(checker, source) {
149733
+ return ts.Debug.checkDefined(autoImportProvider && getInfoWithChecker(autoImportProvider, /*isFromPackageJson*/ true), "Could not find symbol in specified module for code actions");
149734
+ function getInfoWithChecker(checker, isFromPackageJson) {
149753
149735
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
149754
149736
  if (defaultInfo && ts.skipAlias(defaultInfo.symbol, checker) === symbol) {
149755
- return { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(symbol, checker).flags, source: source };
149737
+ return { symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson };
149756
149738
  }
149757
149739
  var named = checker.tryGetMemberInModuleExportsAndProperties(symbol.name, moduleSymbol);
149758
149740
  if (named && ts.skipAlias(named, checker) === symbol) {
149759
- return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, source: source };
149741
+ return { symbol: named, moduleSymbol: moduleSymbol, moduleFileName: undefined, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(symbol, checker).flags, isFromPackageJson: isFromPackageJson };
149760
149742
  }
149761
149743
  }
149762
149744
  }
149763
- function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences) {
149745
+ function getAllReExportingModules(importingFile, targetSymbol, exportingModuleSymbol, symbolName, isJsxTagName, host, program, preferences, useAutoImportProvider) {
149764
149746
  var result = [];
149765
149747
  var compilerOptions = program.getCompilerOptions();
149766
- var getModuleSpecifierResolutionHost = ts.memoizeOne(function (source) {
149767
- return ts.createModuleSpecifierResolutionHost(ts.getProgramForAutoImport(source, program, host), host);
149748
+ var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
149749
+ return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
149768
149750
  });
149769
- ts.forEachExternalModuleToImportFrom(program, host, preferences, function (moduleSymbol, moduleFile, program, source) {
149751
+ ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, moduleFile, program, isFromPackageJson) {
149770
149752
  var checker = program.getTypeChecker();
149771
149753
  // Don't import from a re-export when looking "up" like to `./index` or `../index`.
149772
149754
  if (moduleFile && moduleSymbol !== exportingModuleSymbol && ts.startsWith(importingFile.fileName, ts.getDirectoryPath(moduleFile.fileName))) {
149773
149755
  return;
149774
149756
  }
149775
149757
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
149776
- if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, source)) {
149777
- result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, source: source });
149758
+ if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && ts.skipAlias(defaultInfo.symbol, checker) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
149759
+ result.push({ symbol: defaultInfo.symbol, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: defaultInfo.exportKind, targetFlags: ts.skipAlias(defaultInfo.symbol, checker).flags, isFromPackageJson: isFromPackageJson });
149778
149760
  }
149779
149761
  for (var _i = 0, _a = checker.getExportsAndPropertiesOfModule(moduleSymbol); _i < _a.length; _i++) {
149780
149762
  var exported = _a[_i];
149781
- if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, source)) {
149782
- result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, source: source });
149763
+ if (exported.name === symbolName && checker.getMergedSymbol(ts.skipAlias(exported, checker)) === targetSymbol && isImportable(program, moduleFile, isFromPackageJson)) {
149764
+ result.push({ symbol: exported, moduleSymbol: moduleSymbol, moduleFileName: moduleFile === null || moduleFile === void 0 ? void 0 : moduleFile.fileName, exportKind: 0 /* Named */, targetFlags: ts.skipAlias(exported, checker).flags, isFromPackageJson: isFromPackageJson });
149783
149765
  }
149784
149766
  }
149785
149767
  });
149786
149768
  return result;
149787
- function isImportable(program, moduleFile, source) {
149769
+ function isImportable(program, moduleFile, isFromPackageJson) {
149788
149770
  var _a;
149789
- return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(source), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
149771
+ return !moduleFile || ts.isImportableFile(program, importingFile, moduleFile, preferences, /*packageJsonFilter*/ undefined, getModuleSpecifierResolutionHost(isFromPackageJson), (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host));
149790
149772
  }
149791
149773
  }
149792
149774
  function getModuleSpecifierForBestExportInfo(exportInfo, importingFile, program, host, preferences, packageJsonImportFilter, fromCacheOnly) {
@@ -149968,13 +149950,13 @@ var ts;
149968
149950
  var isJs = ts.isSourceFileJS(sourceFile);
149969
149951
  var compilerOptions = program.getCompilerOptions();
149970
149952
  var moduleSpecifierResolutionHost = ts.createModuleSpecifierResolutionHost(program, host);
149971
- var getProgramForAutoImport = ts.createMemoizedGetProgramForAutoImport(program, host);
149953
+ var getChecker = ts.memoizeOne(function (isFromPackageJson) { return isFromPackageJson ? host.getPackageJsonAutoImportProvider().getTypeChecker() : program.getTypeChecker(); });
149972
149954
  var getModuleSpecifiers = fromCacheOnly
149973
149955
  ? function (moduleSymbol) { return ({ moduleSpecifiers: ts.moduleSpecifiers.tryGetModuleSpecifiersFromCache(moduleSymbol, sourceFile, moduleSpecifierResolutionHost, preferences), computedWithoutCache: false }); }
149974
149956
  : function (moduleSymbol, checker) { return ts.moduleSpecifiers.getModuleSpecifiersWithCacheInfo(moduleSymbol, checker, compilerOptions, sourceFile, moduleSpecifierResolutionHost, preferences); };
149975
149957
  var computedWithoutCacheCount = 0;
149976
149958
  var fixes = ts.flatMap(moduleSymbols, function (exportInfo) {
149977
- var checker = getProgramForAutoImport(exportInfo.source).getTypeChecker();
149959
+ var checker = getChecker(exportInfo.isFromPackageJson);
149978
149960
  var _a = getModuleSpecifiers(exportInfo.moduleSymbol, checker), computedWithoutCache = _a.computedWithoutCache, moduleSpecifiers = _a.moduleSpecifiers;
149979
149961
  var importedSymbolHasValueMeaning = !!(exportInfo.targetFlags & 111551 /* Value */);
149980
149962
  var addAsTypeOnly = getAddAsTypeOnly(isValidTypeOnlyUseSite, /*isForNewImportDeclaration*/ true, exportInfo.symbol, exportInfo.targetFlags, checker, compilerOptions);
@@ -150009,7 +149991,7 @@ var ts;
150009
149991
  return { kind: 3 /* AddNew */, moduleSpecifier: moduleSpecifier, importKind: importKind, addAsTypeOnly: addAsTypeOnly, useRequire: useRequire };
150010
149992
  }
150011
149993
  }
150012
- function getFixesInfo(context, errorCode, pos) {
149994
+ function getFixesInfo(context, errorCode, pos, useAutoImportProvider) {
150013
149995
  var symbolToken = ts.getTokenAtPosition(context.sourceFile, pos);
150014
149996
  var info;
150015
149997
  if (errorCode === ts.Diagnostics._0_refers_to_a_UMD_global_but_the_current_file_is_a_module_Consider_adding_an_import_instead.code) {
@@ -150024,7 +150006,7 @@ var ts;
150024
150006
  return fix && { fixes: [fix], symbolName: symbolName_1, errorIdentifierText: symbolToken.text };
150025
150007
  }
150026
150008
  else {
150027
- info = getFixesInfoForNonUMDImport(context, symbolToken);
150009
+ info = getFixesInfoForNonUMDImport(context, symbolToken, useAutoImportProvider);
150028
150010
  }
150029
150011
  var packageJsonImportFilter = ts.createPackageJsonImportFilter(context.sourceFile, context.preferences, context.host);
150030
150012
  return info && __assign(__assign({}, info), { fixes: sortFixes(info.fixes, context.sourceFile, context.program, packageJsonImportFilter) });
@@ -150074,7 +150056,7 @@ var ts;
150074
150056
  return undefined;
150075
150057
  var symbol = checker.getAliasedSymbol(umdSymbol);
150076
150058
  var symbolName = umdSymbol.name;
150077
- var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, source: 1 /* Program */ }];
150059
+ var exportInfos = [{ symbol: umdSymbol, moduleSymbol: symbol, moduleFileName: undefined, exportKind: 3 /* UMD */, targetFlags: symbol.flags, isFromPackageJson: false }];
150078
150060
  var useRequire = shouldUseRequire(sourceFile, program);
150079
150061
  var fixes = getImportFixes(exportInfos, symbolName, ts.isIdentifier(token) ? token.getStart(sourceFile) : undefined, /*isValidTypeOnlyUseSite*/ false, useRequire, program, sourceFile, host, preferences);
150080
150062
  return { fixes: fixes, symbolName: symbolName, errorIdentifierText: (_b = ts.tryCast(token, ts.isIdentifier)) === null || _b === void 0 ? void 0 : _b.text };
@@ -150134,7 +150116,7 @@ var ts;
150134
150116
  return ts.Debug.assertNever(moduleKind, "Unexpected moduleKind " + moduleKind);
150135
150117
  }
150136
150118
  }
150137
- function getFixesInfoForNonUMDImport(_a, symbolToken) {
150119
+ function getFixesInfoForNonUMDImport(_a, symbolToken, useAutoImportProvider) {
150138
150120
  var sourceFile = _a.sourceFile, program = _a.program, cancellationToken = _a.cancellationToken, host = _a.host, preferences = _a.preferences;
150139
150121
  var checker = program.getTypeChecker();
150140
150122
  var compilerOptions = program.getCompilerOptions();
@@ -150143,7 +150125,7 @@ var ts;
150143
150125
  ts.Debug.assert(symbolName !== "default" /* Default */, "'default' isn't a legal identifier and couldn't occur here");
150144
150126
  var isValidTypeOnlyUseSite = ts.isValidTypeOnlyAliasUseSite(symbolToken);
150145
150127
  var useRequire = shouldUseRequire(sourceFile, program);
150146
- var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, host, preferences);
150128
+ var exportInfos = getExportInfos(symbolName, ts.isJSXTagName(symbolToken), ts.getMeaningFromLocation(symbolToken), cancellationToken, sourceFile, program, useAutoImportProvider, host, preferences);
150147
150129
  var fixes = ts.arrayFrom(ts.flatMapIterator(exportInfos.entries(), function (_a) {
150148
150130
  var _ = _a[0], exportInfos = _a[1];
150149
150131
  return getImportFixes(exportInfos, symbolName, symbolToken.getStart(sourceFile), isValidTypeOnlyUseSite, useRequire, program, sourceFile, host, preferences);
@@ -150180,36 +150162,36 @@ var ts;
150180
150162
  return !namespaceSymbol || ts.some(namespaceSymbol.declarations, ts.isTypeOnlyImportOrExportDeclaration) && !(namespaceSymbol.flags & 111551 /* Value */);
150181
150163
  }
150182
150164
  // Returns a map from an exported symbol's ID to a list of every way it's (re-)exported.
150183
- function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, host, preferences) {
150165
+ function getExportInfos(symbolName, isJsxTagName, currentTokenMeaning, cancellationToken, fromFile, program, useAutoImportProvider, host, preferences) {
150184
150166
  var _a;
150185
150167
  // For each original symbol, keep all re-exports of that symbol together so we can call `getCodeActionsForImport` on the whole group at once.
150186
150168
  // Maps symbol id to info for modules providing that symbol (original export + re-exports).
150187
150169
  var originalSymbolToExportInfos = ts.createMultiMap();
150188
150170
  var packageJsonFilter = ts.createPackageJsonImportFilter(fromFile, preferences, host);
150189
150171
  var moduleSpecifierCache = (_a = host.getModuleSpecifierCache) === null || _a === void 0 ? void 0 : _a.call(host);
150190
- var getModuleSpecifierResolutionHost = ts.memoizeOne(function (source) {
150191
- return ts.createModuleSpecifierResolutionHost(ts.getProgramForAutoImport(source, program, host), host);
150172
+ var getModuleSpecifierResolutionHost = ts.memoizeOne(function (isFromPackageJson) {
150173
+ return ts.createModuleSpecifierResolutionHost(isFromPackageJson ? host.getPackageJsonAutoImportProvider() : program, host);
150192
150174
  });
150193
- function addSymbol(moduleSymbol, toFile, exportedSymbol, exportKind, program, source) {
150194
- var moduleSpecifierResolutionHost = getModuleSpecifierResolutionHost(source);
150175
+ function addSymbol(moduleSymbol, toFile, exportedSymbol, exportKind, program, isFromPackageJson) {
150176
+ var moduleSpecifierResolutionHost = getModuleSpecifierResolutionHost(isFromPackageJson);
150195
150177
  if (toFile && ts.isImportableFile(program, fromFile, toFile, preferences, packageJsonFilter, moduleSpecifierResolutionHost, moduleSpecifierCache) ||
150196
150178
  !toFile && packageJsonFilter.allowsImportingAmbientModule(moduleSymbol, moduleSpecifierResolutionHost)) {
150197
150179
  var checker = program.getTypeChecker();
150198
- originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, moduleFileName: toFile === null || toFile === void 0 ? void 0 : toFile.fileName, exportKind: exportKind, targetFlags: ts.skipAlias(exportedSymbol, checker).flags, source: source });
150180
+ originalSymbolToExportInfos.add(ts.getUniqueSymbolId(exportedSymbol, checker).toString(), { symbol: exportedSymbol, moduleSymbol: moduleSymbol, moduleFileName: toFile === null || toFile === void 0 ? void 0 : toFile.fileName, exportKind: exportKind, targetFlags: ts.skipAlias(exportedSymbol, checker).flags, isFromPackageJson: isFromPackageJson });
150199
150181
  }
150200
150182
  }
150201
- ts.forEachExternalModuleToImportFrom(program, host, preferences, function (moduleSymbol, sourceFile, program, source) {
150183
+ ts.forEachExternalModuleToImportFrom(program, host, useAutoImportProvider, function (moduleSymbol, sourceFile, program, isFromPackageJson) {
150202
150184
  var checker = program.getTypeChecker();
150203
150185
  cancellationToken.throwIfCancellationRequested();
150204
150186
  var compilerOptions = program.getCompilerOptions();
150205
150187
  var defaultInfo = ts.getDefaultLikeExportInfo(moduleSymbol, checker, compilerOptions);
150206
150188
  if (defaultInfo && (defaultInfo.name === symbolName || moduleSymbolToValidIdentifier(moduleSymbol, ts.getEmitScriptTarget(compilerOptions), isJsxTagName) === symbolName) && symbolHasMeaning(defaultInfo.symbolForMeaning, currentTokenMeaning)) {
150207
- addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, source);
150189
+ addSymbol(moduleSymbol, sourceFile, defaultInfo.symbol, defaultInfo.exportKind, program, isFromPackageJson);
150208
150190
  }
150209
150191
  // check exports with the same name
150210
150192
  var exportSymbolWithIdenticalName = checker.tryGetMemberInModuleExportsAndProperties(symbolName, moduleSymbol);
150211
150193
  if (exportSymbolWithIdenticalName && symbolHasMeaning(exportSymbolWithIdenticalName, currentTokenMeaning)) {
150212
- addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, source);
150194
+ addSymbol(moduleSymbol, sourceFile, exportSymbolWithIdenticalName, 0 /* Named */, program, isFromPackageJson);
150213
150195
  }
150214
150196
  });
150215
150197
  return originalSymbolToExportInfos;
@@ -151276,7 +151258,7 @@ var ts;
151276
151258
  });
151277
151259
  typeDeclToMembers.forEach(function (infos, classDeclaration) {
151278
151260
  var supers = codefix.getAllSupers(classDeclaration, checker);
151279
- var _loop_16 = function (info) {
151261
+ var _loop_15 = function (info) {
151280
151262
  // If some superclass added this property, don't add it again.
151281
151263
  if (supers.some(function (superClassOrInterface) {
151282
151264
  var superInfos = typeDeclToMembers.get(superClassOrInterface);
@@ -151303,7 +151285,7 @@ var ts;
151303
151285
  };
151304
151286
  for (var _i = 0, infos_1 = infos; _i < infos_1.length; _i++) {
151305
151287
  var info = infos_1[_i];
151306
- _loop_16(info);
151288
+ _loop_15(info);
151307
151289
  }
151308
151290
  });
151309
151291
  }));
@@ -153895,7 +153877,7 @@ var ts;
153895
153877
  function getSignatureFromCalls(calls) {
153896
153878
  var parameters = [];
153897
153879
  var length = Math.max.apply(Math, calls.map(function (c) { return c.argumentTypes.length; }));
153898
- var _loop_17 = function (i) {
153880
+ var _loop_16 = function (i) {
153899
153881
  var symbol = checker.createSymbol(1 /* FunctionScopedVariable */, ts.escapeLeadingUnderscores("arg" + i));
153900
153882
  symbol.type = combineTypes(calls.map(function (call) { return call.argumentTypes[i] || checker.getUndefinedType(); }));
153901
153883
  if (calls.some(function (call) { return call.argumentTypes[i] === undefined; })) {
@@ -153904,7 +153886,7 @@ var ts;
153904
153886
  parameters.push(symbol);
153905
153887
  };
153906
153888
  for (var i = 0; i < length; i++) {
153907
- _loop_17(i);
153889
+ _loop_16(i);
153908
153890
  }
153909
153891
  var returnType = combineFromUsage(combineUsages(calls.map(function (call) { return call.return_; })));
153910
153892
  return checker.createSignature(/*declaration*/ undefined, /*typeParameters*/ undefined, /*thisParameter*/ undefined, parameters, returnType, /*typePredicate*/ undefined, length, 0 /* None */);
@@ -155845,7 +155827,7 @@ var ts;
155845
155827
  // Imports that need to be kept as named imports in the refactored code, to avoid changing the semantics.
155846
155828
  // More specifically, those are named imports that appear in named exports in the original code, e.g. `a` in `import { a } from "m"; export { a }`.
155847
155829
  var neededNamedImports = new ts.Set();
155848
- var _loop_18 = function (element) {
155830
+ var _loop_17 = function (element) {
155849
155831
  var propertyName = (element.propertyName || element.name).text;
155850
155832
  ts.FindAllReferences.Core.eachSymbolReferenceInFile(element.name, checker, sourceFile, function (id) {
155851
155833
  var access = ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(namespaceImportName), propertyName);
@@ -155862,7 +155844,7 @@ var ts;
155862
155844
  };
155863
155845
  for (var _i = 0, _a = toConvert.elements; _i < _a.length; _i++) {
155864
155846
  var element = _a[_i];
155865
- _loop_18(element);
155847
+ _loop_17(element);
155866
155848
  }
155867
155849
  changes.replaceNode(sourceFile, toConvert, ts.factory.createNamespaceImport(ts.factory.createIdentifier(namespaceImportName)));
155868
155850
  if (neededNamedImports.size) {
@@ -157717,7 +157699,7 @@ var ts;
157717
157699
  : ts.getEnclosingBlockScopeContainer(scopes[0]);
157718
157700
  ts.forEachChild(containingLexicalScopeOfExtraction, checkForUsedDeclarations);
157719
157701
  }
157720
- var _loop_19 = function (i) {
157702
+ var _loop_18 = function (i) {
157721
157703
  var scopeUsages = usagesPerScope[i];
157722
157704
  // Special case: in the innermost scope, all usages are available.
157723
157705
  // (The computed value reflects the value at the top-level of the scope, but the
@@ -157757,7 +157739,7 @@ var ts;
157757
157739
  }
157758
157740
  };
157759
157741
  for (var i = 0; i < scopes.length; i++) {
157760
- _loop_19(i);
157742
+ _loop_18(i);
157761
157743
  }
157762
157744
  return { target: target, usagesPerScope: usagesPerScope, functionErrorsPerScope: functionErrorsPerScope, constantErrorsPerScope: constantErrorsPerScope, exposedVariableDeclarations: exposedVariableDeclarations };
157763
157745
  function isInGenericContext(node) {
@@ -158455,10 +158437,10 @@ var ts;
158455
158437
  }
158456
158438
  function updateImportsInOtherFiles(changes, program, oldFile, movedSymbols, newModuleName) {
158457
158439
  var checker = program.getTypeChecker();
158458
- var _loop_20 = function (sourceFile) {
158440
+ var _loop_19 = function (sourceFile) {
158459
158441
  if (sourceFile === oldFile)
158460
158442
  return "continue";
158461
- var _loop_21 = function (statement) {
158443
+ var _loop_20 = function (statement) {
158462
158444
  forEachImportInStatement(statement, function (importNode) {
158463
158445
  if (checker.getSymbolAtLocation(moduleSpecifierFromImport(importNode)) !== oldFile.symbol)
158464
158446
  return;
@@ -158480,12 +158462,12 @@ var ts;
158480
158462
  };
158481
158463
  for (var _b = 0, _c = sourceFile.statements; _b < _c.length; _b++) {
158482
158464
  var statement = _c[_b];
158483
- _loop_21(statement);
158465
+ _loop_20(statement);
158484
158466
  }
158485
158467
  };
158486
158468
  for (var _i = 0, _a = program.getSourceFiles(); _i < _a.length; _i++) {
158487
158469
  var sourceFile = _a[_i];
158488
- _loop_20(sourceFile);
158470
+ _loop_19(sourceFile);
158489
158471
  }
158490
158472
  }
158491
158473
  function getNamespaceLikeImport(node) {
@@ -159151,7 +159133,7 @@ var ts;
159151
159133
  var convertParamsToDestructuredObject;
159152
159134
  (function (convertParamsToDestructuredObject) {
159153
159135
  var refactorName = "Convert parameters to destructured object";
159154
- var minimumParameterLength = 2;
159136
+ var minimumParameterLength = 1;
159155
159137
  var refactorDescription = ts.getLocaleSpecificMessage(ts.Diagnostics.Convert_parameters_to_destructured_object);
159156
159138
  var toDestructuredAction = {
159157
159139
  name: refactorName,
@@ -159849,7 +159831,7 @@ var ts;
159849
159831
  var templateSpans = [];
159850
159832
  var templateHead = ts.factory.createTemplateHead(headText, rawHeadText);
159851
159833
  copyCommentFromStringLiterals(headIndexes, templateHead);
159852
- var _loop_22 = function (i) {
159834
+ var _loop_21 = function (i) {
159853
159835
  var currentNode = getExpressionFromParenthesesOrExpression(nodes[i]);
159854
159836
  copyOperatorComments(i, currentNode);
159855
159837
  var _c = concatConsecutiveString(i + 1, nodes), newIndex = _c[0], subsequentText = _c[1], rawSubsequentText = _c[2], stringIndexes = _c[3];
@@ -159878,7 +159860,7 @@ var ts;
159878
159860
  };
159879
159861
  var out_i_1;
159880
159862
  for (var i = begin; i < nodes.length; i++) {
159881
- _loop_22(i);
159863
+ _loop_21(i);
159882
159864
  i = out_i_1;
159883
159865
  }
159884
159866
  return ts.factory.createTemplateExpression(templateHead, templateSpans);
@@ -160714,7 +160696,7 @@ var ts;
160714
160696
  var tags = ts.JsDoc.getJsDocTagsFromDeclarations(declarations, checker);
160715
160697
  if (checker && (tags.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
160716
160698
  var seenSymbols_1 = new ts.Set();
160717
- var _loop_23 = function (declaration) {
160699
+ var _loop_22 = function (declaration) {
160718
160700
  var inheritedTags = findBaseOfDeclaration(checker, declaration, function (symbol) {
160719
160701
  var _a;
160720
160702
  if (!seenSymbols_1.has(symbol)) {
@@ -160731,7 +160713,7 @@ var ts;
160731
160713
  };
160732
160714
  for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
160733
160715
  var declaration = declarations_6[_i];
160734
- _loop_23(declaration);
160716
+ _loop_22(declaration);
160735
160717
  }
160736
160718
  }
160737
160719
  return tags;
@@ -160742,7 +160724,7 @@ var ts;
160742
160724
  var doc = ts.JsDoc.getJsDocCommentsFromDeclarations(declarations, checker);
160743
160725
  if (checker && (doc.length === 0 || declarations.some(hasJSDocInheritDocTag))) {
160744
160726
  var seenSymbols_2 = new ts.Set();
160745
- var _loop_24 = function (declaration) {
160727
+ var _loop_23 = function (declaration) {
160746
160728
  var inheritedDocs = findBaseOfDeclaration(checker, declaration, function (symbol) {
160747
160729
  if (!seenSymbols_2.has(symbol)) {
160748
160730
  seenSymbols_2.add(symbol);
@@ -160758,7 +160740,7 @@ var ts;
160758
160740
  };
160759
160741
  for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
160760
160742
  var declaration = declarations_7[_i];
160761
- _loop_24(declaration);
160743
+ _loop_23(declaration);
160762
160744
  }
160763
160745
  }
160764
160746
  return doc;
@@ -167141,11 +167123,6 @@ var ts;
167141
167123
  Project.prototype.getIncompleteCompletionsCache = function () {
167142
167124
  return this.projectService.getIncompleteCompletionsCache();
167143
167125
  };
167144
- /*@internal*/
167145
- Project.prototype.getProgramForReferencedProject = function (configFileName) {
167146
- var _a;
167147
- return (_a = this.projectService.findConfiguredProjectByProjectName(server.toNormalizedPath(configFileName))) === null || _a === void 0 ? void 0 : _a.getCurrentProgram();
167148
- };
167149
167126
  return Project;
167150
167127
  }());
167151
167128
  server.Project = Project;