typescript 4.8.0-dev.20220614 → 4.8.0-dev.20220617

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
@@ -92,6 +92,15 @@ var __extends = (this && this.__extends) || (function () {
92
92
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
93
93
  };
94
94
  })();
95
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
96
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
97
+ return new (P || (P = Promise))(function (resolve, reject) {
98
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
99
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
100
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
101
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
102
+ });
103
+ };
95
104
  var ts;
96
105
  (function (ts) {
97
106
  // WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
@@ -100,7 +109,7 @@ var ts;
100
109
  // The following is baselined as a literal template type without intervention
101
110
  /** The version of the TypeScript compiler release */
102
111
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
103
- ts.version = ts.versionMajorMinor + ".0-dev.20220614";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220617";
104
113
  /* @internal */
105
114
  var Comparison;
106
115
  (function (Comparison) {
@@ -8474,9 +8483,11 @@ var ts;
8474
8483
  Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1: diag(2205, ts.DiagnosticCategory.Error, "Construct_signatures_with_no_arguments_have_incompatible_return_types_0_and_1_2205", "Construct signatures with no arguments have incompatible return types '{0}' and '{1}'.", /*reportsUnnecessary*/ undefined, /*elidedInCompatabilityPyramid*/ true),
8475
8484
  The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement: diag(2206, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_import_when_import_type_is_used_on_its_import_statement_2206", "The 'type' modifier cannot be used on a named import when 'import type' is used on its import statement."),
8476
8485
  The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement: diag(2207, ts.DiagnosticCategory.Error, "The_type_modifier_cannot_be_used_on_a_named_export_when_export_type_is_used_on_its_export_statement_2207", "The 'type' modifier cannot be used on a named export when 'export type' is used on its export statement."),
8477
- This_type_parameter_probably_needs_an_extends_object_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_probably_needs_an_extends_object_constraint_2208", "This type parameter probably needs an `extends object` constraint."),
8486
+ This_type_parameter_might_need_an_extends_0_constraint: diag(2208, ts.DiagnosticCategory.Error, "This_type_parameter_might_need_an_extends_0_constraint_2208", "This type parameter might need an `extends {0}` constraint."),
8478
8487
  The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8479
8488
  The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
8489
+ Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
8490
+ Add_extends_constraint_to_all_type_parameters: diag(2212, ts.DiagnosticCategory.Message, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
8480
8491
  Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
8481
8492
  Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
8482
8493
  Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
@@ -8962,6 +8973,8 @@ var ts;
8962
8973
  This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
8963
8974
  An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
8964
8975
  The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
8976
+ _0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
8977
+ We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
8965
8978
  Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
8966
8979
  Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
8967
8980
  Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
@@ -9659,6 +9672,8 @@ var ts;
9659
9672
  Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."),
9660
9673
  A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."),
9661
9674
  The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
9675
+ You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder: diag(8035, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035", "You cannot rename elements that are defined in a 'node_modules' folder."),
9676
+ You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."),
9662
9677
  Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
9663
9678
  Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
9664
9679
  JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
@@ -35776,10 +35791,11 @@ var ts;
35776
35791
  }
35777
35792
  nextToken();
35778
35793
  var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
35779
- if (!parseExpected(31 /* GreaterThanToken */)) {
35794
+ if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
35780
35795
  // If it doesn't have the closing `>` then it's definitely not an type argument list.
35781
35796
  return undefined;
35782
35797
  }
35798
+ nextToken();
35783
35799
  // We successfully parsed a type argument list. The next token determines whether we want to
35784
35800
  // treat it as such. If the type argument list is followed by `(` or a template literal, as in
35785
35801
  // `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
@@ -48896,9 +48912,9 @@ var ts;
48896
48912
  return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
48897
48913
  },
48898
48914
  resolveExternalModuleSymbol: resolveExternalModuleSymbol,
48899
- tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
48915
+ tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
48900
48916
  var node = ts.getParseTreeNode(nodeIn);
48901
- return node && tryGetThisTypeAt(node, includeGlobalThis);
48917
+ return node && tryGetThisTypeAt(node, includeGlobalThis, container);
48902
48918
  },
48903
48919
  getTypeArgumentConstraint: function (nodeIn) {
48904
48920
  var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
@@ -49193,6 +49209,7 @@ var ts;
49193
49209
  var potentialNewTargetCollisions = [];
49194
49210
  var potentialWeakMapSetCollisions = [];
49195
49211
  var potentialReflectCollisions = [];
49212
+ var potentialUnusedRenamedBindingElementsInTypes = [];
49196
49213
  var awaitedTypeStack = [];
49197
49214
  var diagnostics = ts.createDiagnosticCollection();
49198
49215
  var suggestionDiagnostics = ts.createDiagnosticCollection();
@@ -52528,6 +52545,9 @@ var ts;
52528
52545
  if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
52529
52546
  return { accessibility: 0 /* Accessible */ };
52530
52547
  }
52548
+ if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
52549
+ return { accessibility: 0 /* Accessible */ };
52550
+ }
52531
52551
  // Verify if the symbol is accessible
52532
52552
  return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
52533
52553
  accessibility: 1 /* NotAccessible */,
@@ -53700,15 +53720,22 @@ var ts;
53700
53720
  context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
53701
53721
  return parameterNode;
53702
53722
  function cloneBindingName(node) {
53703
- return elideInitializerAndSetEmitFlags(node);
53704
- function elideInitializerAndSetEmitFlags(node) {
53723
+ return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
53724
+ function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
53705
53725
  if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
53706
53726
  trackComputedName(node.expression, context.enclosingDeclaration, context);
53707
53727
  }
53708
- var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags);
53728
+ var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
53709
53729
  if (ts.isBindingElement(visited)) {
53710
- visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
53711
- /*initializer*/ undefined);
53730
+ if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
53731
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
53732
+ /* propertyName*/ undefined, visited.propertyName,
53733
+ /*initializer*/ undefined);
53734
+ }
53735
+ else {
53736
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
53737
+ /*initializer*/ undefined);
53738
+ }
53712
53739
  }
53713
53740
  if (!ts.nodeIsSynthesized(visited)) {
53714
53741
  visited = ts.factory.cloneNode(visited);
@@ -59335,7 +59362,7 @@ var ts;
59335
59362
  }
59336
59363
  if (t.flags & 268435456 /* StringMapping */) {
59337
59364
  var constraint = getBaseConstraint(t.type);
59338
- return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
59365
+ return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
59339
59366
  }
59340
59367
  if (t.flags & 8388608 /* IndexedAccess */) {
59341
59368
  if (isMappedTypeGenericIndexedAccess(t)) {
@@ -62305,9 +62332,12 @@ var ts;
62305
62332
  }
62306
62333
  function getStringMappingType(symbol, type) {
62307
62334
  return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
62308
- isGenericIndexType(type) ? getStringMappingTypeForGenericType(symbol, type) :
62309
- type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62310
- type;
62335
+ // Mapping<Mapping<T>> === Mapping<T>
62336
+ type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
62337
+ isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
62338
+ type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
62339
+ type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
62340
+ type;
62311
62341
  }
62312
62342
  function applyStringMapping(symbol, str) {
62313
62343
  switch (intrinsicTypeKinds.get(symbol.escapedName)) {
@@ -62318,6 +62348,15 @@ var ts;
62318
62348
  }
62319
62349
  return str;
62320
62350
  }
62351
+ function applyTemplateStringMapping(symbol, texts, types) {
62352
+ switch (intrinsicTypeKinds.get(symbol.escapedName)) {
62353
+ case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62354
+ case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
62355
+ case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
62356
+ case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
62357
+ }
62358
+ return [texts, types];
62359
+ }
62321
62360
  function getStringMappingTypeForGenericType(symbol, type) {
62322
62361
  var id = getSymbolId(symbol) + "," + getTypeId(type);
62323
62362
  var result = stringMappingTypes.get(id);
@@ -62559,7 +62598,7 @@ var ts;
62559
62598
  accessNode;
62560
62599
  }
62561
62600
  function isPatternLiteralPlaceholderType(type) {
62562
- return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
62601
+ return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
62563
62602
  }
62564
62603
  function isPatternLiteralType(type) {
62565
62604
  return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
@@ -65481,8 +65520,13 @@ var ts;
65481
65520
  return;
65482
65521
  }
65483
65522
  reportRelationError(headMessage, source, target);
65484
- if (strictNullChecks && source.flags & 8650752 /* TypeVariable */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source) && isRelatedTo(emptyObjectType, extractTypesOfKind(target, ~67108864 /* NonPrimitive */))) {
65485
- associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_probably_needs_an_extends_object_constraint));
65523
+ if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) {
65524
+ var syntheticParam = cloneTypeParameter(source);
65525
+ syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
65526
+ if (hasNonCircularBaseConstraint(syntheticParam)) {
65527
+ var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
65528
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
65529
+ }
65486
65530
  }
65487
65531
  }
65488
65532
  function traceUnionsOrIntersectionsTooLarge(source, target) {
@@ -66266,6 +66310,13 @@ var ts;
66266
66310
  return -1 /* True */;
66267
66311
  }
66268
66312
  }
66313
+ else if (target.flags & 268435456 /* StringMapping */) {
66314
+ if (!(source.flags & 268435456 /* StringMapping */)) {
66315
+ if (isMemberOfStringMapping(source, target)) {
66316
+ return -1 /* True */;
66317
+ }
66318
+ }
66319
+ }
66269
66320
  if (sourceFlags & 8650752 /* TypeVariable */) {
66270
66321
  // IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
66271
66322
  if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
@@ -66309,7 +66360,10 @@ var ts;
66309
66360
  }
66310
66361
  }
66311
66362
  else if (sourceFlags & 268435456 /* StringMapping */) {
66312
- if (targetFlags & 268435456 /* StringMapping */ && source.symbol === target.symbol) {
66363
+ if (targetFlags & 268435456 /* StringMapping */) {
66364
+ if (source.symbol !== target.symbol) {
66365
+ return 0 /* False */;
66366
+ }
66313
66367
  if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
66314
66368
  resetErrorInfo(saveErrorInfo);
66315
66369
  return result;
@@ -67234,7 +67288,7 @@ var ts;
67234
67288
  return typeCouldHaveTopLevelSingletonTypes(constraint);
67235
67289
  }
67236
67290
  }
67237
- return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
67291
+ return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
67238
67292
  }
67239
67293
  function getExactOptionalUnassignableProperties(source, target) {
67240
67294
  if (isTupleType(source) && isTupleType(target))
@@ -68032,12 +68086,13 @@ var ts;
68032
68086
  * with no call or construct signatures.
68033
68087
  */
68034
68088
  function isObjectTypeWithInferableIndex(type) {
68089
+ var objectFlags = ts.getObjectFlags(type);
68035
68090
  return type.flags & 2097152 /* Intersection */
68036
68091
  ? ts.every(type.types, isObjectTypeWithInferableIndex)
68037
68092
  : !!(type.symbol
68038
68093
  && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
68039
68094
  && !(type.symbol.flags & 32 /* Class */)
68040
- && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
68095
+ && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
68041
68096
  }
68042
68097
  function createSymbolWithType(source, type) {
68043
68098
  var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
@@ -68704,6 +68759,31 @@ var ts;
68704
68759
  return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
68705
68760
  && (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
68706
68761
  }
68762
+ function isMemberOfStringMapping(source, target) {
68763
+ if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
68764
+ return true;
68765
+ }
68766
+ if (target.flags & 134217728 /* TemplateLiteral */) {
68767
+ return isTypeAssignableTo(source, target);
68768
+ }
68769
+ if (target.flags & 268435456 /* StringMapping */) {
68770
+ // We need to see whether applying the same mappings of the target
68771
+ // onto the source would produce an identical type *and* that
68772
+ // it's compatible with the inner-most non-string-mapped type.
68773
+ //
68774
+ // The intuition here is that if same mappings don't affect the source at all,
68775
+ // and the source is compatible with the unmapped target, then they must
68776
+ // still reside in the same domain.
68777
+ var mappingStack = [];
68778
+ while (target.flags & 268435456 /* StringMapping */) {
68779
+ mappingStack.unshift(target.symbol);
68780
+ target = target.type;
68781
+ }
68782
+ var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
68783
+ return mappedSource === source && isMemberOfStringMapping(source, target);
68784
+ }
68785
+ return false;
68786
+ }
68707
68787
  function isValidTypeForTemplateLiteralPlaceholder(source, target) {
68708
68788
  if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
68709
68789
  return true;
@@ -68712,7 +68792,8 @@ var ts;
68712
68792
  var value = source.value;
68713
68793
  return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
68714
68794
  target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
68715
- target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName);
68795
+ target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
68796
+ target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
68716
68797
  }
68717
68798
  if (source.flags & 134217728 /* TemplateLiteral */) {
68718
68799
  var texts = source.texts;
@@ -82636,6 +82717,22 @@ var ts;
82636
82717
  }
82637
82718
  });
82638
82719
  }
82720
+ function checkPotentialUncheckedRenamedBindingElementsInTypes() {
82721
+ var _a;
82722
+ for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
82723
+ var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
82724
+ if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
82725
+ var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
82726
+ ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
82727
+ var diagnostic = ts.createDiagnosticForNode(node.name, ts.Diagnostics._0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, ts.declarationNameToString(node.name), ts.declarationNameToString(node.propertyName));
82728
+ if (!wrappingDeclaration.type) {
82729
+ // entire parameter does not have type annotation, suggest adding an annotation
82730
+ ts.addRelatedInfo(diagnostic, ts.createFileDiagnostic(ts.getSourceFileOfNode(wrappingDeclaration), wrappingDeclaration.end, 1, ts.Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here, ts.declarationNameToString(node.propertyName)));
82731
+ }
82732
+ diagnostics.add(diagnostic);
82733
+ }
82734
+ }
82735
+ }
82639
82736
  function bindingNameText(name) {
82640
82737
  switch (name.kind) {
82641
82738
  case 79 /* Identifier */:
@@ -82937,6 +83034,17 @@ var ts;
82937
83034
  }
82938
83035
  }
82939
83036
  if (ts.isBindingElement(node)) {
83037
+ if (node.propertyName &&
83038
+ ts.isIdentifier(node.name) &&
83039
+ ts.isParameterDeclaration(node) &&
83040
+ ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
83041
+ // type F = ({a: string}) => void;
83042
+ // ^^^^^^
83043
+ // variable renaming in function type notation is confusing,
83044
+ // so we forbid it even if noUnusedLocals is not enabled
83045
+ potentialUnusedRenamedBindingElementsInTypes.push(node);
83046
+ return;
83047
+ }
82940
83048
  if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
82941
83049
  checkExternalEmitHelpers(node, 4 /* Rest */);
82942
83050
  }
@@ -86400,6 +86508,7 @@ var ts;
86400
86508
  ts.clear(potentialNewTargetCollisions);
86401
86509
  ts.clear(potentialWeakMapSetCollisions);
86402
86510
  ts.clear(potentialReflectCollisions);
86511
+ ts.clear(potentialUnusedRenamedBindingElementsInTypes);
86403
86512
  ts.forEach(node.statements, checkSourceElement);
86404
86513
  checkSourceElement(node.endOfFileToken);
86405
86514
  checkDeferredNodes(node);
@@ -86415,6 +86524,9 @@ var ts;
86415
86524
  }
86416
86525
  });
86417
86526
  }
86527
+ if (!node.isDeclarationFile) {
86528
+ checkPotentialUncheckedRenamedBindingElementsInTypes();
86529
+ }
86418
86530
  });
86419
86531
  if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
86420
86532
  !node.isDeclarationFile &&
@@ -109156,7 +109268,7 @@ var ts;
109156
109268
  });
109157
109269
  return ret;
109158
109270
  }
109159
- function filterBindingPatternInitializers(name) {
109271
+ function filterBindingPatternInitializersAndRenamings(name) {
109160
109272
  if (name.kind === 79 /* Identifier */) {
109161
109273
  return name;
109162
109274
  }
@@ -109172,7 +109284,12 @@ var ts;
109172
109284
  if (elem.kind === 227 /* OmittedExpression */) {
109173
109285
  return elem;
109174
109286
  }
109175
- return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109287
+ if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
109288
+ // Unnecessary property renaming is forbidden in types, so remove renaming
109289
+ return factory.updateBindingElement(elem, elem.dotDotDotToken,
109290
+ /* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109291
+ }
109292
+ return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109176
109293
  }
109177
109294
  }
109178
109295
  function ensureParameter(p, modifierMask, type) {
@@ -109181,7 +109298,7 @@ var ts;
109181
109298
  oldDiag = getSymbolAccessibilityDiagnostic;
109182
109299
  getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
109183
109300
  }
109184
- var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
109301
+ var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
109185
109302
  ensureNoInitializer(p));
109186
109303
  if (!suppressNewDiagnosticContexts) {
109187
109304
  getSymbolAccessibilityDiagnostic = oldDiag;
@@ -117324,6 +117441,7 @@ var ts;
117324
117441
  ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
117325
117442
  ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
117326
117443
  ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
117444
+ ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
117327
117445
  ]);
117328
117446
  /**
117329
117447
  * Determine if source file needs to be re-created even if its text hasn't changed
@@ -134714,7 +134832,7 @@ var ts;
134714
134832
  }
134715
134833
  // Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
134716
134834
  if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
134717
- var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
134835
+ var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
134718
134836
  if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
134719
134837
  for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
134720
134838
  var symbol = _a[_i];
@@ -144052,10 +144170,10 @@ var ts;
144052
144170
  (function (ts) {
144053
144171
  var Rename;
144054
144172
  (function (Rename) {
144055
- function getRenameInfo(program, sourceFile, position, options) {
144173
+ function getRenameInfo(program, sourceFile, position, preferences) {
144056
144174
  var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
144057
144175
  if (nodeIsEligibleForRename(node)) {
144058
- var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, options);
144176
+ var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
144059
144177
  if (renameInfo) {
144060
144178
  return renameInfo;
144061
144179
  }
@@ -144063,7 +144181,7 @@ var ts;
144063
144181
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
144064
144182
  }
144065
144183
  Rename.getRenameInfo = getRenameInfo;
144066
- function getRenameInfoForNode(node, typeChecker, sourceFile, program, options) {
144184
+ function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
144067
144185
  var symbol = typeChecker.getSymbolAtLocation(node);
144068
144186
  if (!symbol) {
144069
144187
  if (ts.isStringLiteralLike(node)) {
@@ -144091,7 +144209,12 @@ var ts;
144091
144209
  return undefined;
144092
144210
  }
144093
144211
  if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
144094
- return options && options.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144212
+ return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
144213
+ }
144214
+ // Disallow rename for elements that would rename across `*/node_modules/*` packages.
144215
+ var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
144216
+ if (wouldRenameNodeModules) {
144217
+ return getRenameInfoError(wouldRenameNodeModules);
144095
144218
  }
144096
144219
  var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
144097
144220
  var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
@@ -144105,6 +144228,49 @@ var ts;
144105
144228
  var sourceFile = declaration.getSourceFile();
144106
144229
  return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
144107
144230
  }
144231
+ function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
144232
+ if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
144233
+ var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
144234
+ if (importSpecifier && !importSpecifier.propertyName) {
144235
+ symbol = checker.getAliasedSymbol(symbol);
144236
+ }
144237
+ }
144238
+ var declarations = symbol.declarations;
144239
+ if (!declarations) {
144240
+ return undefined;
144241
+ }
144242
+ var originalPackage = getPackagePathComponents(originalFile.path);
144243
+ if (originalPackage === undefined) { // original source file is not in node_modules
144244
+ if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
144245
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
144246
+ }
144247
+ else {
144248
+ return undefined;
144249
+ }
144250
+ }
144251
+ // original source file is in node_modules
144252
+ for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
144253
+ var declaration = declarations_4[_i];
144254
+ var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
144255
+ if (declPackage) {
144256
+ var length_2 = Math.min(originalPackage.length, declPackage.length);
144257
+ for (var i = 0; i <= length_2; i++) {
144258
+ if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
144259
+ return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
144260
+ }
144261
+ }
144262
+ }
144263
+ }
144264
+ return undefined;
144265
+ }
144266
+ function getPackagePathComponents(filePath) {
144267
+ var components = ts.getPathComponents(filePath);
144268
+ var nodeModulesIdx = components.lastIndexOf("node_modules");
144269
+ if (nodeModulesIdx === -1) {
144270
+ return undefined;
144271
+ }
144272
+ return components.slice(0, nodeModulesIdx + 2);
144273
+ }
144108
144274
  function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
144109
144275
  if (!ts.isExternalModuleNameRelative(node.text)) {
144110
144276
  return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
@@ -145159,7 +145325,7 @@ var ts;
145159
145325
  return type.symbol && (type.symbol.flags & 1536 /* Module */);
145160
145326
  }
145161
145327
  function visitVariableLikeDeclaration(decl) {
145162
- if (!decl.initializer || ts.isBindingPattern(decl.name)) {
145328
+ if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
145163
145329
  return;
145164
145330
  }
145165
145331
  var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
@@ -145287,6 +145453,9 @@ var ts;
145287
145453
  }
145288
145454
  for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
145289
145455
  var param = node.parameters[i];
145456
+ if (!isHintableDeclaration(param)) {
145457
+ continue;
145458
+ }
145290
145459
  var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
145291
145460
  if (effectiveTypeAnnotation) {
145292
145461
  continue;
@@ -145328,6 +145497,13 @@ var ts;
145328
145497
  function isUndefined(name) {
145329
145498
  return name === "undefined";
145330
145499
  }
145500
+ function isHintableDeclaration(node) {
145501
+ if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
145502
+ var initializer = ts.skipParentheses(node.initializer);
145503
+ return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
145504
+ }
145505
+ return true;
145506
+ }
145331
145507
  }
145332
145508
  InlayHints.provideInlayHints = provideInlayHints;
145333
145509
  })(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
@@ -154766,6 +154942,77 @@ var ts;
154766
154942
  })(ts || (ts = {}));
154767
154943
  /* @internal */
154768
154944
  var ts;
154945
+ (function (ts) {
154946
+ var codefix;
154947
+ (function (codefix) {
154948
+ var fixId = "addMissingConstraint";
154949
+ var errorCodes = [
154950
+ // We want errors this could be attached to:
154951
+ // Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
154952
+ ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code,
154953
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
154954
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
154955
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
154956
+ ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
154957
+ ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
154958
+ ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
154959
+ ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
154960
+ ];
154961
+ codefix.registerCodeFix({
154962
+ errorCodes: errorCodes,
154963
+ getCodeActions: function (context) {
154964
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
154965
+ var related = getDiagnosticRelatedInfo(program, sourceFile, span);
154966
+ if (!related) {
154967
+ return;
154968
+ }
154969
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
154970
+ return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
154971
+ },
154972
+ fixIds: [fixId],
154973
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
154974
+ var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
154975
+ if (!info)
154976
+ return;
154977
+ return addMissingConstraint(changes, info);
154978
+ }); },
154979
+ });
154980
+ function getDiagnosticRelatedInfo(program, sourceFile, span) {
154981
+ var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
154982
+ if (!diag || !diag.relatedInformation)
154983
+ return;
154984
+ var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
154985
+ if (!related)
154986
+ return;
154987
+ return related;
154988
+ }
154989
+ function addMissingConstraint(changes, related) {
154990
+ var decl = findAncestorMatchingSpan(related.file, related);
154991
+ if (!decl)
154992
+ return;
154993
+ if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) {
154994
+ decl = decl.parent;
154995
+ }
154996
+ if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
154997
+ return; // should only issue fix on type parameters written using `extends`
154998
+ var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
154999
+ if (!newConstraint)
155000
+ return;
155001
+ var newConstraintText = newConstraint[1];
155002
+ changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
155003
+ }
155004
+ function findAncestorMatchingSpan(sourceFile, span) {
155005
+ var token = ts.getTokenAtPosition(sourceFile, span.start);
155006
+ var end = ts.textSpanEnd(span);
155007
+ while (token.end < end) {
155008
+ token = token.parent;
155009
+ }
155010
+ return token;
155011
+ }
155012
+ })(codefix = ts.codefix || (ts.codefix = {}));
155013
+ })(ts || (ts = {}));
155014
+ /* @internal */
155015
+ var ts;
154769
155016
  (function (ts) {
154770
155017
  var codefix;
154771
155018
  (function (codefix) {
@@ -161063,11 +161310,11 @@ var ts;
161063
161310
  }
161064
161311
  }
161065
161312
  else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
161066
- var declarations_5 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161313
+ var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
161067
161314
  var numInitializers = 0;
161068
161315
  var lastInitializer = void 0;
161069
- for (var _i = 0, declarations_4 = declarations_5; _i < declarations_4.length; _i++) {
161070
- var declaration = declarations_4[_i];
161316
+ for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
161317
+ var declaration = declarations_5[_i];
161071
161318
  if (declaration.initializer) {
161072
161319
  numInitializers++;
161073
161320
  lastInitializer = declaration.initializer;
@@ -165204,8 +165451,8 @@ var ts;
165204
165451
  tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
165205
165452
  }
165206
165453
  };
165207
- for (var _i = 0, declarations_6 = declarations; _i < declarations_6.length; _i++) {
165208
- var declaration = declarations_6[_i];
165454
+ for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165455
+ var declaration = declarations_7[_i];
165209
165456
  _loop_21(declaration);
165210
165457
  }
165211
165458
  }
@@ -165231,8 +165478,8 @@ var ts;
165231
165478
  if (inheritedDocs)
165232
165479
  doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
165233
165480
  };
165234
- for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
165235
- var declaration = declarations_7[_i];
165481
+ for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
165482
+ var declaration = declarations_8[_i];
165236
165483
  _loop_22(declaration);
165237
165484
  }
165238
165485
  }
@@ -166809,9 +167056,9 @@ var ts;
166809
167056
  return ts.stringContains(path, "/node_modules/");
166810
167057
  }
166811
167058
  }
166812
- function getRenameInfo(fileName, position, options) {
167059
+ function getRenameInfo(fileName, position, preferences) {
166813
167060
  synchronizeHostData();
166814
- return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, options);
167061
+ return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
166815
167062
  }
166816
167063
  function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
166817
167064
  var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
@@ -168177,9 +168424,9 @@ var ts;
168177
168424
  var _this = this;
168178
168425
  return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
168179
168426
  };
168180
- LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, options) {
168427
+ LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
168181
168428
  var _this = this;
168182
- return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, options); });
168429
+ return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
168183
168430
  };
168184
168431
  LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
168185
168432
  var _this = this;
@@ -170396,6 +170643,38 @@ var ts;
170396
170643
  }
170397
170644
  return result.module;
170398
170645
  };
170646
+ /*@internal*/
170647
+ Project.importServicePluginAsync = function (moduleName, initialDir, host, log, logErrors) {
170648
+ return __awaiter(this, void 0, void 0, function () {
170649
+ var resolvedPath, result, e_1, err;
170650
+ return __generator(this, function (_a) {
170651
+ switch (_a.label) {
170652
+ case 0:
170653
+ ts.Debug.assertIsDefined(host.importServicePlugin);
170654
+ resolvedPath = ts.combinePaths(initialDir, "node_modules");
170655
+ log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
170656
+ _a.label = 1;
170657
+ case 1:
170658
+ _a.trys.push([1, 3, , 4]);
170659
+ return [4 /*yield*/, host.importServicePlugin(resolvedPath, moduleName)];
170660
+ case 2:
170661
+ result = _a.sent();
170662
+ return [3 /*break*/, 4];
170663
+ case 3:
170664
+ e_1 = _a.sent();
170665
+ result = { module: undefined, error: e_1 };
170666
+ return [3 /*break*/, 4];
170667
+ case 4:
170668
+ if (result.error) {
170669
+ err = result.error.stack || result.error.message || JSON.stringify(result.error);
170670
+ (logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err);
170671
+ return [2 /*return*/, undefined];
170672
+ }
170673
+ return [2 /*return*/, result.module];
170674
+ }
170675
+ });
170676
+ });
170677
+ };
170399
170678
  Project.prototype.isKnownTypesPackageName = function (name) {
170400
170679
  return this.typingsCache.isKnownTypesPackageName(name);
170401
170680
  };
@@ -171456,7 +171735,7 @@ var ts;
171456
171735
  };
171457
171736
  Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
171458
171737
  var host = this.projectService.host;
171459
- if (!host.require) {
171738
+ if (!host.require && !host.importServicePlugin) {
171460
171739
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
171461
171740
  return;
171462
171741
  }
@@ -171485,21 +171764,66 @@ var ts;
171485
171764
  }
171486
171765
  }
171487
171766
  };
171488
- Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171767
+ /**
171768
+ * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'.
171769
+ */
171770
+ /*@internal*/
171771
+ Project.prototype.beginEnablePluginSync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171489
171772
  var _this = this;
171490
- this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
171491
- if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
171492
- this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
171493
- return;
171494
- }
171495
- var log = function (message) { return _this.projectService.logger.info(message); };
171773
+ ts.Debug.assertIsDefined(this.projectService.host.require);
171496
171774
  var errorLogs;
171775
+ var log = function (message) { return _this.projectService.logger.info(message); };
171497
171776
  var logError = function (message) {
171498
- (errorLogs || (errorLogs = [])).push(message);
171777
+ (errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
171499
171778
  };
171500
171779
  var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
171501
171780
  return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
171502
171781
  });
171782
+ return { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs };
171783
+ };
171784
+ /**
171785
+ * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`.
171786
+ */
171787
+ /*@internal*/
171788
+ Project.prototype.beginEnablePluginAsync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171789
+ return __awaiter(this, void 0, void 0, function () {
171790
+ var errorLogs, log, logError, resolvedModule, _i, searchPaths_1, searchPath;
171791
+ var _this = this;
171792
+ return __generator(this, function (_a) {
171793
+ switch (_a.label) {
171794
+ case 0:
171795
+ ts.Debug.assertIsDefined(this.projectService.host.importServicePlugin);
171796
+ log = function (message) { return _this.projectService.logger.info(message); };
171797
+ logError = function (message) {
171798
+ (errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
171799
+ };
171800
+ _i = 0, searchPaths_1 = searchPaths;
171801
+ _a.label = 1;
171802
+ case 1:
171803
+ if (!(_i < searchPaths_1.length)) return [3 /*break*/, 4];
171804
+ searchPath = searchPaths_1[_i];
171805
+ return [4 /*yield*/, Project.importServicePluginAsync(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError)];
171806
+ case 2:
171807
+ resolvedModule = (_a.sent());
171808
+ if (resolvedModule !== undefined) {
171809
+ return [3 /*break*/, 4];
171810
+ }
171811
+ _a.label = 3;
171812
+ case 3:
171813
+ _i++;
171814
+ return [3 /*break*/, 1];
171815
+ case 4: return [2 /*return*/, { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs }];
171816
+ }
171817
+ });
171818
+ });
171819
+ };
171820
+ /**
171821
+ * Performs the remaining steps of enabling a plugin after its module has been instantiated.
171822
+ */
171823
+ /*@internal*/
171824
+ Project.prototype.endEnablePlugin = function (_a) {
171825
+ var _this = this;
171826
+ var pluginConfigEntry = _a.pluginConfigEntry, pluginConfigOverrides = _a.pluginConfigOverrides, resolvedModule = _a.resolvedModule, errorLogs = _a.errorLogs;
171503
171827
  if (resolvedModule) {
171504
171828
  var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
171505
171829
  if (configurationOverride) {
@@ -171511,10 +171835,13 @@ var ts;
171511
171835
  this.enableProxy(resolvedModule, pluginConfigEntry);
171512
171836
  }
171513
171837
  else {
171514
- ts.forEach(errorLogs, log);
171838
+ ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); });
171515
171839
  this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
171516
171840
  }
171517
171841
  };
171842
+ Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171843
+ this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths, pluginConfigOverrides);
171844
+ };
171518
171845
  Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) {
171519
171846
  try {
171520
171847
  if (typeof pluginModuleFactory !== "function") {
@@ -172166,7 +172493,7 @@ var ts;
172166
172493
  /*@internal*/
172167
172494
  ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
172168
172495
  var host = this.projectService.host;
172169
- if (!host.require) {
172496
+ if (!host.require && !host.importServicePlugin) {
172170
172497
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
172171
172498
  return;
172172
172499
  }
@@ -172185,7 +172512,7 @@ var ts;
172185
172512
  this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
172186
172513
  }
172187
172514
  }
172188
- this.enableGlobalPlugins(options, pluginConfigOverrides);
172515
+ return this.enableGlobalPlugins(options, pluginConfigOverrides);
172189
172516
  };
172190
172517
  /**
172191
172518
  * Get the errors that dont have any file name associated
@@ -175607,6 +175934,147 @@ var ts;
175607
175934
  }
175608
175935
  return false;
175609
175936
  };
175937
+ /*@internal*/
175938
+ ProjectService.prototype.requestEnablePlugin = function (project, pluginConfigEntry, searchPaths, pluginConfigOverrides) {
175939
+ var _a;
175940
+ if (!this.host.importServicePlugin && !this.host.require) {
175941
+ this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
175942
+ return;
175943
+ }
175944
+ this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
175945
+ if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
175946
+ this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
175947
+ return;
175948
+ }
175949
+ // If the host supports dynamic import, begin enabling the plugin asynchronously.
175950
+ if (this.host.importServicePlugin) {
175951
+ var importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides);
175952
+ (_a = this.pendingPluginEnablements) !== null && _a !== void 0 ? _a : (this.pendingPluginEnablements = new ts.Map());
175953
+ var promises = this.pendingPluginEnablements.get(project);
175954
+ if (!promises)
175955
+ this.pendingPluginEnablements.set(project, promises = []);
175956
+ promises.push(importPromise);
175957
+ return;
175958
+ }
175959
+ // Otherwise, load the plugin using `require`
175960
+ project.endEnablePlugin(project.beginEnablePluginSync(pluginConfigEntry, searchPaths, pluginConfigOverrides));
175961
+ };
175962
+ /* @internal */
175963
+ ProjectService.prototype.hasNewPluginEnablementRequests = function () {
175964
+ return !!this.pendingPluginEnablements;
175965
+ };
175966
+ /* @internal */
175967
+ ProjectService.prototype.hasPendingPluginEnablements = function () {
175968
+ return !!this.currentPluginEnablementPromise;
175969
+ };
175970
+ /**
175971
+ * Waits for any ongoing plugin enablement requests to complete.
175972
+ */
175973
+ /* @internal */
175974
+ ProjectService.prototype.waitForPendingPlugins = function () {
175975
+ return __awaiter(this, void 0, void 0, function () {
175976
+ return __generator(this, function (_a) {
175977
+ switch (_a.label) {
175978
+ case 0:
175979
+ if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
175980
+ return [4 /*yield*/, this.currentPluginEnablementPromise];
175981
+ case 1:
175982
+ _a.sent();
175983
+ return [3 /*break*/, 0];
175984
+ case 2: return [2 /*return*/];
175985
+ }
175986
+ });
175987
+ });
175988
+ };
175989
+ /**
175990
+ * Starts enabling any requested plugins without waiting for the result.
175991
+ */
175992
+ /* @internal */
175993
+ ProjectService.prototype.enableRequestedPlugins = function () {
175994
+ if (this.pendingPluginEnablements) {
175995
+ void this.enableRequestedPluginsAsync();
175996
+ }
175997
+ };
175998
+ ProjectService.prototype.enableRequestedPluginsAsync = function () {
175999
+ return __awaiter(this, void 0, void 0, function () {
176000
+ var entries;
176001
+ return __generator(this, function (_a) {
176002
+ switch (_a.label) {
176003
+ case 0:
176004
+ if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
176005
+ // If we're already enabling plugins, wait for any existing operations to complete
176006
+ return [4 /*yield*/, this.waitForPendingPlugins()];
176007
+ case 1:
176008
+ // If we're already enabling plugins, wait for any existing operations to complete
176009
+ _a.sent();
176010
+ _a.label = 2;
176011
+ case 2:
176012
+ // Skip if there are no new plugin enablement requests
176013
+ if (!this.pendingPluginEnablements) {
176014
+ return [2 /*return*/];
176015
+ }
176016
+ entries = ts.arrayFrom(this.pendingPluginEnablements.entries());
176017
+ this.pendingPluginEnablements = undefined;
176018
+ // Start processing the requests, keeping track of the promise for the operation so that
176019
+ // project consumers can potentially wait for the plugins to load.
176020
+ this.currentPluginEnablementPromise = this.enableRequestedPluginsWorker(entries);
176021
+ return [4 /*yield*/, this.currentPluginEnablementPromise];
176022
+ case 3:
176023
+ _a.sent();
176024
+ return [2 /*return*/];
176025
+ }
176026
+ });
176027
+ });
176028
+ };
176029
+ ProjectService.prototype.enableRequestedPluginsWorker = function (pendingPlugins) {
176030
+ return __awaiter(this, void 0, void 0, function () {
176031
+ var _this = this;
176032
+ return __generator(this, function (_a) {
176033
+ switch (_a.label) {
176034
+ case 0:
176035
+ // This should only be called from `enableRequestedPluginsAsync`, which ensures this precondition is met.
176036
+ ts.Debug.assert(this.currentPluginEnablementPromise === undefined);
176037
+ // Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
176038
+ // on a project with many plugins.
176039
+ return [4 /*yield*/, Promise.all(ts.map(pendingPlugins, function (_a) {
176040
+ var project = _a[0], promises = _a[1];
176041
+ return _this.enableRequestedPluginsForProjectAsync(project, promises);
176042
+ }))];
176043
+ case 1:
176044
+ // Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
176045
+ // on a project with many plugins.
176046
+ _a.sent();
176047
+ // Clear the pending operation and notify the client that projects have been updated.
176048
+ this.currentPluginEnablementPromise = undefined;
176049
+ this.sendProjectsUpdatedInBackgroundEvent();
176050
+ return [2 /*return*/];
176051
+ }
176052
+ });
176053
+ });
176054
+ };
176055
+ ProjectService.prototype.enableRequestedPluginsForProjectAsync = function (project, promises) {
176056
+ return __awaiter(this, void 0, void 0, function () {
176057
+ var results, _i, results_1, result;
176058
+ return __generator(this, function (_a) {
176059
+ switch (_a.label) {
176060
+ case 0: return [4 /*yield*/, Promise.all(promises)];
176061
+ case 1:
176062
+ results = _a.sent();
176063
+ if (project.isClosed()) {
176064
+ // project is not alive, so don't enable plugins.
176065
+ return [2 /*return*/];
176066
+ }
176067
+ for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
176068
+ result = results_1[_i];
176069
+ project.endEnablePlugin(result);
176070
+ }
176071
+ // Plugins may have modified external files, so mark the project as dirty.
176072
+ this.delayUpdateProjectGraph(project);
176073
+ return [2 /*return*/];
176074
+ }
176075
+ });
176076
+ });
176077
+ };
175610
176078
  ProjectService.prototype.configurePlugin = function (args) {
175611
176079
  // For any projects that already have the plugin loaded, configure the plugin
175612
176080
  this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); });
@@ -176128,7 +176596,7 @@ var ts;
176128
176596
  return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
176129
176597
  }
176130
176598
  function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
176131
- var _a;
176599
+ var _a, _b;
176132
176600
  var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
176133
176601
  /*isForRename*/ false, function (project, position) {
176134
176602
  logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
@@ -176148,7 +176616,7 @@ var ts;
176148
176616
  // have started the other project searches from related symbols. Propagate the
176149
176617
  // correct results to all other projects.
176150
176618
  var defaultProjectResults = perProjectResults.get(defaultProject);
176151
- if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null || _a === void 0 ? void 0 : _a.isDefinition) === undefined) {
176619
+ if (((_b = (_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined) {
176152
176620
  // Clear all isDefinition properties
176153
176621
  perProjectResults.forEach(function (projectResults) {
176154
176622
  for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
@@ -176165,8 +176633,8 @@ var ts;
176165
176633
  var knownSymbolSpans_1 = createDocumentSpanSet();
176166
176634
  for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
176167
176635
  var referencedSymbol = defaultProjectResults_1[_i];
176168
- for (var _b = 0, _c = referencedSymbol.references; _b < _c.length; _b++) {
176169
- var ref = _c[_b];
176636
+ for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
176637
+ var ref = _d[_c];
176170
176638
  if (ref.isDefinition) {
176171
176639
  knownSymbolSpans_1.add(ref);
176172
176640
  // One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
@@ -176285,23 +176753,30 @@ var ts;
176285
176753
  var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
176286
176754
  defaultDefinition :
176287
176755
  defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
176288
- // Track which projects we have already searched so that we don't repeat searches.
176289
- // We store the project key, rather than the project, because that's what `loadAncestorProjectTree` wants.
176290
- // (For that same reason, we don't use `resultsMap` for this check.)
176291
- var searchedProjects = new ts.Set();
176756
+ // The keys of resultsMap allow us to check which projects have already been searched, but we also
176757
+ // maintain a set of strings because that's what `loadAncestorProjectTree` wants.
176758
+ var searchedProjectKeys = new ts.Set();
176292
176759
  onCancellation: while (queue.length) {
176293
176760
  while (queue.length) {
176294
176761
  if (cancellationToken.isCancellationRequested())
176295
176762
  break onCancellation;
176763
+ var skipCount = 0;
176764
+ for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++)
176765
+ ;
176766
+ if (skipCount === queue.length) {
176767
+ queue.length = 0;
176768
+ break;
176769
+ }
176770
+ if (skipCount > 0) {
176771
+ queue.splice(0, skipCount);
176772
+ }
176773
+ // NB: we may still skip if it's a project reference redirect
176296
176774
  var _a = queue.shift(), project = _a.project, location = _a.location;
176297
176775
  if (isLocationProjectReferenceRedirect(project, location))
176298
176776
  continue;
176299
- if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
176300
- continue;
176301
176777
  var projectResults = searchPosition(project, location);
176302
- if (projectResults) {
176303
- resultsMap.set(project, projectResults);
176304
- }
176778
+ resultsMap.set(project, projectResults !== null && projectResults !== void 0 ? projectResults : server.emptyArray);
176779
+ searchedProjectKeys.add(getProjectKey(project));
176305
176780
  }
176306
176781
  // At this point, we know about all projects passed in as arguments and any projects in which
176307
176782
  // `getResultsForPosition` has returned results. We expand that set to include any projects
@@ -176309,11 +176784,11 @@ var ts;
176309
176784
  // containing `initialLocation`.
176310
176785
  if (defaultDefinition) {
176311
176786
  // This seems to mean "load all projects downstream from any member of `seenProjects`".
176312
- projectService.loadAncestorProjectTree(searchedProjects);
176787
+ projectService.loadAncestorProjectTree(searchedProjectKeys);
176313
176788
  projectService.forEachEnabledProject(function (project) {
176314
176789
  if (cancellationToken.isCancellationRequested())
176315
176790
  return; // There's no mechanism for skipping the remaining projects
176316
- if (searchedProjects.has(getProjectKey(project)))
176791
+ if (resultsMap.has(project))
176317
176792
  return; // Can loop forever without this (enqueue here, dequeue above, repeat)
176318
176793
  var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
176319
176794
  if (location) {
@@ -176324,9 +176799,10 @@ var ts;
176324
176799
  }
176325
176800
  // In the common case where there's only one project, return a simpler result to make
176326
176801
  // it easier for the caller to skip post-processing.
176327
- if (searchedProjects.size === 1) {
176802
+ if (resultsMap.size === 1) {
176328
176803
  var it = resultsMap.values().next();
176329
- return it.done ? server.emptyArray : it.value; // There may not be any results at all
176804
+ ts.Debug.assert(!it.done);
176805
+ return it.value;
176330
176806
  }
176331
176807
  return resultsMap;
176332
176808
  function searchPosition(project, location) {
@@ -176343,7 +176819,7 @@ var ts;
176343
176819
  var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
176344
176820
  for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
176345
176821
  var project_1 = _a[_i];
176346
- if (!project_1.isOrphan()) {
176822
+ if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded
176347
176823
  queue.push({ project: project_1, location: originalLocation });
176348
176824
  }
176349
176825
  }
@@ -176352,7 +176828,7 @@ var ts;
176352
176828
  symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
176353
176829
  for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
176354
176830
  var symlinkedProject = symlinkedProjects_2[_i];
176355
- if (!symlinkedProject.isOrphan()) {
176831
+ if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
176356
176832
  queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
176357
176833
  }
176358
176834
  }
@@ -176435,7 +176911,6 @@ var ts;
176435
176911
  server.CommandNames.OrganizeImportsFull,
176436
176912
  server.CommandNames.GetEditsForFileRename,
176437
176913
  server.CommandNames.GetEditsForFileRenameFull,
176438
- server.CommandNames.ConfigurePlugin,
176439
176914
  server.CommandNames.PrepareCallHierarchy,
176440
176915
  server.CommandNames.ProvideCallHierarchyIncomingCalls,
176441
176916
  server.CommandNames.ProvideCallHierarchyOutgoingCalls,
@@ -177646,7 +178121,8 @@ var ts;
177646
178121
  Session.prototype.getRenameInfo = function (args) {
177647
178122
  var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
177648
178123
  var position = this.getPositionInFile(args, file);
177649
- return project.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath });
178124
+ var preferences = this.getPreferences(file);
178125
+ return project.getLanguageService().getRenameInfo(file, position, preferences);
177650
178126
  };
177651
178127
  Session.prototype.getProjects = function (args, getScriptInfoEnsuringProjectsUptoDate, ignoreNoProjectError) {
177652
178128
  var _a;
@@ -177697,10 +178173,11 @@ var ts;
177697
178173
  var position = this.getPositionInFile(args, file);
177698
178174
  var projects = this.getProjects(args);
177699
178175
  var defaultProject = this.getDefaultProject(args);
177700
- var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, { allowRenameOfImportPath: this.getPreferences(file).allowRenameOfImportPath }), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
178176
+ var preferences = this.getPreferences(file);
178177
+ var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, preferences), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
177701
178178
  if (!renameInfo.canRename)
177702
178179
  return simplifiedResult ? { info: renameInfo, locs: [] } : [];
177703
- var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, this.getPreferences(file));
178180
+ var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, preferences);
177704
178181
  if (!simplifiedResult)
177705
178182
  return locations;
177706
178183
  return { info: renameInfo, locs: this.toSpanGroups(locations) };
@@ -178703,7 +179180,9 @@ var ts;
178703
179180
  Session.prototype.executeCommand = function (request) {
178704
179181
  var handler = this.handlers.get(request.command);
178705
179182
  if (handler) {
178706
- return this.executeWithRequestId(request.seq, function () { return handler(request); });
179183
+ var response = this.executeWithRequestId(request.seq, function () { return handler(request); });
179184
+ this.projectService.enableRequestedPlugins();
179185
+ return response;
178707
179186
  }
178708
179187
  else {
178709
179188
  this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err);
@@ -179617,6 +180096,8 @@ var ts;
179617
180096
  })(server = ts.server || (ts.server = {}));
179618
180097
  })(ts || (ts = {}));
179619
180098
  /*@internal*/
180099
+ /// <reference lib="dom" />
180100
+ /// <reference lib="webworker.importscripts" />
179620
180101
  var ts;
179621
180102
  (function (ts) {
179622
180103
  var server;
@@ -179722,11 +180203,31 @@ var ts;
179722
180203
  return MainProcessLogger;
179723
180204
  }(BaseLogger));
179724
180205
  server.MainProcessLogger = MainProcessLogger;
180206
+ // Attempt to load `dynamicImport`
180207
+ if (typeof importScripts === "function") {
180208
+ try {
180209
+ // NOTE: importScripts is synchronous
180210
+ importScripts("dynamicImportCompat.js");
180211
+ }
180212
+ catch (_a) {
180213
+ // ignored
180214
+ }
180215
+ }
179725
180216
  function createWebSystem(host, args, getExecutingFilePath) {
180217
+ var _this = this;
179726
180218
  var returnEmptyString = function () { return ""; };
179727
180219
  var getExecutingDirectoryPath = ts.memoize(function () { return ts.memoize(function () { return ts.ensureTrailingDirectorySeparator(ts.getDirectoryPath(getExecutingFilePath())); }); });
179728
180220
  // Later we could map ^memfs:/ to do something special if we want to enable more functionality like module resolution or something like that
179729
180221
  var getWebPath = function (path) { return ts.startsWith(path, ts.directorySeparator) ? path.replace(ts.directorySeparator, getExecutingDirectoryPath()) : undefined; };
180222
+ var dynamicImport = function (id) { return __awaiter(_this, void 0, void 0, function () {
180223
+ return __generator(this, function (_a) {
180224
+ // Use syntactic dynamic import first, if available
180225
+ if (server.dynamicImport) {
180226
+ return [2 /*return*/, server.dynamicImport(id)];
180227
+ }
180228
+ throw new Error("Dynamic import not implemented");
180229
+ });
180230
+ }); };
179730
180231
  return {
179731
180232
  args: args,
179732
180233
  newLine: "\r\n",
@@ -179752,7 +180253,45 @@ var ts;
179752
180253
  setImmediate: function (x) { return setTimeout(x, 0); },
179753
180254
  clearImmediate: function (handle) { return clearTimeout(handle); },
179754
180255
  /* eslint-enable no-restricted-globals */
179755
- require: function () { return ({ module: undefined, error: new Error("Not implemented") }); },
180256
+ importServicePlugin: function (initialDir, moduleName) { return __awaiter(_this, void 0, void 0, function () {
180257
+ var packageRoot, packageJson, packageJsonResponse, e_1, browser, scriptPath, module_1, e_2;
180258
+ return __generator(this, function (_a) {
180259
+ switch (_a.label) {
180260
+ case 0:
180261
+ packageRoot = ts.combinePaths(initialDir, moduleName);
180262
+ _a.label = 1;
180263
+ case 1:
180264
+ _a.trys.push([1, 4, , 5]);
180265
+ return [4 /*yield*/, fetch(ts.combinePaths(packageRoot, "package.json"))];
180266
+ case 2:
180267
+ packageJsonResponse = _a.sent();
180268
+ return [4 /*yield*/, packageJsonResponse.json()];
180269
+ case 3:
180270
+ packageJson = _a.sent();
180271
+ return [3 /*break*/, 5];
180272
+ case 4:
180273
+ e_1 = _a.sent();
180274
+ return [2 /*return*/, { module: undefined, error: new Error("Could not load plugin. Could not load 'package.json'.") }];
180275
+ case 5:
180276
+ browser = packageJson.browser;
180277
+ if (!browser) {
180278
+ return [2 /*return*/, { module: undefined, error: new Error("Could not load plugin. No 'browser' field found in package.json.") }];
180279
+ }
180280
+ scriptPath = ts.combinePaths(packageRoot, browser);
180281
+ _a.label = 6;
180282
+ case 6:
180283
+ _a.trys.push([6, 8, , 9]);
180284
+ return [4 /*yield*/, dynamicImport(scriptPath)];
180285
+ case 7:
180286
+ module_1 = (_a.sent()).default;
180287
+ return [2 /*return*/, { module: module_1, error: undefined }];
180288
+ case 8:
180289
+ e_2 = _a.sent();
180290
+ return [2 /*return*/, { module: undefined, error: e_2 }];
180291
+ case 9: return [2 /*return*/];
180292
+ }
180293
+ });
180294
+ }); },
179756
180295
  exit: ts.notImplemented,
179757
180296
  // Debugging related
179758
180297
  getEnvironmentVariable: returnEmptyString,