typescript 4.8.0-dev.20220613 → 4.8.0-dev.20220616

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.20220613";
112
+ ts.version = ts.versionMajorMinor + ".0-dev.20220616";
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}'."),
@@ -35776,10 +35789,11 @@ var ts;
35776
35789
  }
35777
35790
  nextToken();
35778
35791
  var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
35779
- if (!parseExpected(31 /* GreaterThanToken */)) {
35792
+ if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
35780
35793
  // If it doesn't have the closing `>` then it's definitely not an type argument list.
35781
35794
  return undefined;
35782
35795
  }
35796
+ nextToken();
35783
35797
  // We successfully parsed a type argument list. The next token determines whether we want to
35784
35798
  // treat it as such. If the type argument list is followed by `(` or a template literal, as in
35785
35799
  // `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
@@ -49193,6 +49207,7 @@ var ts;
49193
49207
  var potentialNewTargetCollisions = [];
49194
49208
  var potentialWeakMapSetCollisions = [];
49195
49209
  var potentialReflectCollisions = [];
49210
+ var potentialUnusedRenamedBindingElementsInTypes = [];
49196
49211
  var awaitedTypeStack = [];
49197
49212
  var diagnostics = ts.createDiagnosticCollection();
49198
49213
  var suggestionDiagnostics = ts.createDiagnosticCollection();
@@ -52528,6 +52543,9 @@ var ts;
52528
52543
  if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
52529
52544
  return { accessibility: 0 /* Accessible */ };
52530
52545
  }
52546
+ if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
52547
+ return { accessibility: 0 /* Accessible */ };
52548
+ }
52531
52549
  // Verify if the symbol is accessible
52532
52550
  return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
52533
52551
  accessibility: 1 /* NotAccessible */,
@@ -53700,15 +53718,22 @@ var ts;
53700
53718
  context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
53701
53719
  return parameterNode;
53702
53720
  function cloneBindingName(node) {
53703
- return elideInitializerAndSetEmitFlags(node);
53704
- function elideInitializerAndSetEmitFlags(node) {
53721
+ return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
53722
+ function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
53705
53723
  if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
53706
53724
  trackComputedName(node.expression, context.enclosingDeclaration, context);
53707
53725
  }
53708
- var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags);
53726
+ var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
53709
53727
  if (ts.isBindingElement(visited)) {
53710
- visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
53711
- /*initializer*/ undefined);
53728
+ if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
53729
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
53730
+ /* propertyName*/ undefined, visited.propertyName,
53731
+ /*initializer*/ undefined);
53732
+ }
53733
+ else {
53734
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
53735
+ /*initializer*/ undefined);
53736
+ }
53712
53737
  }
53713
53738
  if (!ts.nodeIsSynthesized(visited)) {
53714
53739
  visited = ts.factory.cloneNode(visited);
@@ -64918,7 +64943,7 @@ var ts;
64918
64943
  return true;
64919
64944
  if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
64920
64945
  return true;
64921
- if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
64946
+ if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */)))
64922
64947
  return true;
64923
64948
  if (relation === assignableRelation || relation === comparableRelation) {
64924
64949
  if (s & 1 /* Any */)
@@ -65481,8 +65506,13 @@ var ts;
65481
65506
  return;
65482
65507
  }
65483
65508
  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));
65509
+ 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)) {
65510
+ var syntheticParam = cloneTypeParameter(source);
65511
+ syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
65512
+ if (hasNonCircularBaseConstraint(syntheticParam)) {
65513
+ var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
65514
+ associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
65515
+ }
65486
65516
  }
65487
65517
  }
65488
65518
  function traceUnionsOrIntersectionsTooLarge(source, target) {
@@ -65621,7 +65651,7 @@ var ts;
65621
65651
  return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
65622
65652
  }
65623
65653
  if (target.flags & 2097152 /* Intersection */) {
65624
- return typeRelatedToEachType(getRegularTypeOfObjectLiteral(source), target, reportErrors, 2 /* Target */);
65654
+ return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */);
65625
65655
  }
65626
65656
  // Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
65627
65657
  // constraints of all non-primitive types in the source into a new intersection. We do this because the
@@ -68032,12 +68062,13 @@ var ts;
68032
68062
  * with no call or construct signatures.
68033
68063
  */
68034
68064
  function isObjectTypeWithInferableIndex(type) {
68065
+ var objectFlags = ts.getObjectFlags(type);
68035
68066
  return type.flags & 2097152 /* Intersection */
68036
68067
  ? ts.every(type.types, isObjectTypeWithInferableIndex)
68037
68068
  : !!(type.symbol
68038
68069
  && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
68039
68070
  && !(type.symbol.flags & 32 /* Class */)
68040
- && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
68071
+ && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
68041
68072
  }
68042
68073
  function createSymbolWithType(source, type) {
68043
68074
  var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
@@ -82636,6 +82667,22 @@ var ts;
82636
82667
  }
82637
82668
  });
82638
82669
  }
82670
+ function checkPotentialUncheckedRenamedBindingElementsInTypes() {
82671
+ var _a;
82672
+ for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
82673
+ var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
82674
+ if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
82675
+ var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
82676
+ ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
82677
+ 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));
82678
+ if (!wrappingDeclaration.type) {
82679
+ // entire parameter does not have type annotation, suggest adding an annotation
82680
+ 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)));
82681
+ }
82682
+ diagnostics.add(diagnostic);
82683
+ }
82684
+ }
82685
+ }
82639
82686
  function bindingNameText(name) {
82640
82687
  switch (name.kind) {
82641
82688
  case 79 /* Identifier */:
@@ -82937,6 +82984,17 @@ var ts;
82937
82984
  }
82938
82985
  }
82939
82986
  if (ts.isBindingElement(node)) {
82987
+ if (node.propertyName &&
82988
+ ts.isIdentifier(node.name) &&
82989
+ ts.isParameterDeclaration(node) &&
82990
+ ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
82991
+ // type F = ({a: string}) => void;
82992
+ // ^^^^^^
82993
+ // variable renaming in function type notation is confusing,
82994
+ // so we forbid it even if noUnusedLocals is not enabled
82995
+ potentialUnusedRenamedBindingElementsInTypes.push(node);
82996
+ return;
82997
+ }
82940
82998
  if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
82941
82999
  checkExternalEmitHelpers(node, 4 /* Rest */);
82942
83000
  }
@@ -86400,6 +86458,7 @@ var ts;
86400
86458
  ts.clear(potentialNewTargetCollisions);
86401
86459
  ts.clear(potentialWeakMapSetCollisions);
86402
86460
  ts.clear(potentialReflectCollisions);
86461
+ ts.clear(potentialUnusedRenamedBindingElementsInTypes);
86403
86462
  ts.forEach(node.statements, checkSourceElement);
86404
86463
  checkSourceElement(node.endOfFileToken);
86405
86464
  checkDeferredNodes(node);
@@ -86415,6 +86474,9 @@ var ts;
86415
86474
  }
86416
86475
  });
86417
86476
  }
86477
+ if (!node.isDeclarationFile) {
86478
+ checkPotentialUncheckedRenamedBindingElementsInTypes();
86479
+ }
86418
86480
  });
86419
86481
  if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
86420
86482
  !node.isDeclarationFile &&
@@ -109156,7 +109218,7 @@ var ts;
109156
109218
  });
109157
109219
  return ret;
109158
109220
  }
109159
- function filterBindingPatternInitializers(name) {
109221
+ function filterBindingPatternInitializersAndRenamings(name) {
109160
109222
  if (name.kind === 79 /* Identifier */) {
109161
109223
  return name;
109162
109224
  }
@@ -109172,7 +109234,12 @@ var ts;
109172
109234
  if (elem.kind === 227 /* OmittedExpression */) {
109173
109235
  return elem;
109174
109236
  }
109175
- return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109237
+ if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
109238
+ // Unnecessary property renaming is forbidden in types, so remove renaming
109239
+ return factory.updateBindingElement(elem, elem.dotDotDotToken,
109240
+ /* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109241
+ }
109242
+ return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109176
109243
  }
109177
109244
  }
109178
109245
  function ensureParameter(p, modifierMask, type) {
@@ -109181,7 +109248,7 @@ var ts;
109181
109248
  oldDiag = getSymbolAccessibilityDiagnostic;
109182
109249
  getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
109183
109250
  }
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
109251
+ 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
109252
  ensureNoInitializer(p));
109186
109253
  if (!suppressNewDiagnosticContexts) {
109187
109254
  getSymbolAccessibilityDiagnostic = oldDiag;
@@ -117324,6 +117391,7 @@ var ts;
117324
117391
  ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
117325
117392
  ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
117326
117393
  ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
117394
+ ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
117327
117395
  ]);
117328
117396
  /**
117329
117397
  * Determine if source file needs to be re-created even if its text hasn't changed
@@ -122458,9 +122526,11 @@ var ts;
122458
122526
  }
122459
122527
  function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
122460
122528
  ts.Debug.assert(!!resolution.refCount);
122529
+ var affectingLocations = resolution.affectingLocations;
122530
+ if (!affectingLocations.length)
122531
+ return;
122461
122532
  if (addToResolutionsWithOnlyAffectingLocations)
122462
122533
  resolutionsWithOnlyAffectingLocations.push(resolution);
122463
- var affectingLocations = resolution.affectingLocations;
122464
122534
  // Watch package json
122465
122535
  for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
122466
122536
  var affectingLocation = affectingLocations_1[_i];
@@ -145157,7 +145227,7 @@ var ts;
145157
145227
  return type.symbol && (type.symbol.flags & 1536 /* Module */);
145158
145228
  }
145159
145229
  function visitVariableLikeDeclaration(decl) {
145160
- if (!decl.initializer || ts.isBindingPattern(decl.name)) {
145230
+ if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
145161
145231
  return;
145162
145232
  }
145163
145233
  var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
@@ -145285,6 +145355,9 @@ var ts;
145285
145355
  }
145286
145356
  for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
145287
145357
  var param = node.parameters[i];
145358
+ if (!isHintableDeclaration(param)) {
145359
+ continue;
145360
+ }
145288
145361
  var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
145289
145362
  if (effectiveTypeAnnotation) {
145290
145363
  continue;
@@ -145326,6 +145399,13 @@ var ts;
145326
145399
  function isUndefined(name) {
145327
145400
  return name === "undefined";
145328
145401
  }
145402
+ function isHintableDeclaration(node) {
145403
+ if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
145404
+ var initializer = ts.skipParentheses(node.initializer);
145405
+ return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
145406
+ }
145407
+ return true;
145408
+ }
145329
145409
  }
145330
145410
  InlayHints.provideInlayHints = provideInlayHints;
145331
145411
  })(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
@@ -154764,6 +154844,77 @@ var ts;
154764
154844
  })(ts || (ts = {}));
154765
154845
  /* @internal */
154766
154846
  var ts;
154847
+ (function (ts) {
154848
+ var codefix;
154849
+ (function (codefix) {
154850
+ var fixId = "addMissingConstraint";
154851
+ var errorCodes = [
154852
+ // We want errors this could be attached to:
154853
+ // Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
154854
+ ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code,
154855
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
154856
+ 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,
154857
+ ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
154858
+ 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,
154859
+ ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
154860
+ ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
154861
+ ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
154862
+ ];
154863
+ codefix.registerCodeFix({
154864
+ errorCodes: errorCodes,
154865
+ getCodeActions: function (context) {
154866
+ var sourceFile = context.sourceFile, span = context.span, program = context.program;
154867
+ var related = getDiagnosticRelatedInfo(program, sourceFile, span);
154868
+ if (!related) {
154869
+ return;
154870
+ }
154871
+ var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
154872
+ return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
154873
+ },
154874
+ fixIds: [fixId],
154875
+ getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
154876
+ var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
154877
+ if (!info)
154878
+ return;
154879
+ return addMissingConstraint(changes, info);
154880
+ }); },
154881
+ });
154882
+ function getDiagnosticRelatedInfo(program, sourceFile, span) {
154883
+ var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
154884
+ if (!diag || !diag.relatedInformation)
154885
+ return;
154886
+ var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
154887
+ if (!related)
154888
+ return;
154889
+ return related;
154890
+ }
154891
+ function addMissingConstraint(changes, related) {
154892
+ var decl = findAncestorMatchingSpan(related.file, related);
154893
+ if (!decl)
154894
+ return;
154895
+ if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) {
154896
+ decl = decl.parent;
154897
+ }
154898
+ if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
154899
+ return; // should only issue fix on type parameters written using `extends`
154900
+ var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
154901
+ if (!newConstraint)
154902
+ return;
154903
+ var newConstraintText = newConstraint[1];
154904
+ changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
154905
+ }
154906
+ function findAncestorMatchingSpan(sourceFile, span) {
154907
+ var token = ts.getTokenAtPosition(sourceFile, span.start);
154908
+ var end = ts.textSpanEnd(span);
154909
+ while (token.end < end) {
154910
+ token = token.parent;
154911
+ }
154912
+ return token;
154913
+ }
154914
+ })(codefix = ts.codefix || (ts.codefix = {}));
154915
+ })(ts || (ts = {}));
154916
+ /* @internal */
154917
+ var ts;
154767
154918
  (function (ts) {
154768
154919
  var codefix;
154769
154920
  (function (codefix) {
@@ -170394,6 +170545,38 @@ var ts;
170394
170545
  }
170395
170546
  return result.module;
170396
170547
  };
170548
+ /*@internal*/
170549
+ Project.importServicePluginAsync = function (moduleName, initialDir, host, log, logErrors) {
170550
+ return __awaiter(this, void 0, void 0, function () {
170551
+ var resolvedPath, result, e_1, err;
170552
+ return __generator(this, function (_a) {
170553
+ switch (_a.label) {
170554
+ case 0:
170555
+ ts.Debug.assertIsDefined(host.importServicePlugin);
170556
+ resolvedPath = ts.combinePaths(initialDir, "node_modules");
170557
+ log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
170558
+ _a.label = 1;
170559
+ case 1:
170560
+ _a.trys.push([1, 3, , 4]);
170561
+ return [4 /*yield*/, host.importServicePlugin(resolvedPath, moduleName)];
170562
+ case 2:
170563
+ result = _a.sent();
170564
+ return [3 /*break*/, 4];
170565
+ case 3:
170566
+ e_1 = _a.sent();
170567
+ result = { module: undefined, error: e_1 };
170568
+ return [3 /*break*/, 4];
170569
+ case 4:
170570
+ if (result.error) {
170571
+ err = result.error.stack || result.error.message || JSON.stringify(result.error);
170572
+ (logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err);
170573
+ return [2 /*return*/, undefined];
170574
+ }
170575
+ return [2 /*return*/, result.module];
170576
+ }
170577
+ });
170578
+ });
170579
+ };
170397
170580
  Project.prototype.isKnownTypesPackageName = function (name) {
170398
170581
  return this.typingsCache.isKnownTypesPackageName(name);
170399
170582
  };
@@ -171454,7 +171637,7 @@ var ts;
171454
171637
  };
171455
171638
  Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
171456
171639
  var host = this.projectService.host;
171457
- if (!host.require) {
171640
+ if (!host.require && !host.importServicePlugin) {
171458
171641
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
171459
171642
  return;
171460
171643
  }
@@ -171483,21 +171666,66 @@ var ts;
171483
171666
  }
171484
171667
  }
171485
171668
  };
171486
- Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171669
+ /**
171670
+ * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'.
171671
+ */
171672
+ /*@internal*/
171673
+ Project.prototype.beginEnablePluginSync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171487
171674
  var _this = this;
171488
- this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
171489
- if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
171490
- this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
171491
- return;
171492
- }
171493
- var log = function (message) { return _this.projectService.logger.info(message); };
171675
+ ts.Debug.assertIsDefined(this.projectService.host.require);
171494
171676
  var errorLogs;
171677
+ var log = function (message) { return _this.projectService.logger.info(message); };
171495
171678
  var logError = function (message) {
171496
- (errorLogs || (errorLogs = [])).push(message);
171679
+ (errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
171497
171680
  };
171498
171681
  var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
171499
171682
  return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
171500
171683
  });
171684
+ return { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs };
171685
+ };
171686
+ /**
171687
+ * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`.
171688
+ */
171689
+ /*@internal*/
171690
+ Project.prototype.beginEnablePluginAsync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171691
+ return __awaiter(this, void 0, void 0, function () {
171692
+ var errorLogs, log, logError, resolvedModule, _i, searchPaths_1, searchPath;
171693
+ var _this = this;
171694
+ return __generator(this, function (_a) {
171695
+ switch (_a.label) {
171696
+ case 0:
171697
+ ts.Debug.assertIsDefined(this.projectService.host.importServicePlugin);
171698
+ log = function (message) { return _this.projectService.logger.info(message); };
171699
+ logError = function (message) {
171700
+ (errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
171701
+ };
171702
+ _i = 0, searchPaths_1 = searchPaths;
171703
+ _a.label = 1;
171704
+ case 1:
171705
+ if (!(_i < searchPaths_1.length)) return [3 /*break*/, 4];
171706
+ searchPath = searchPaths_1[_i];
171707
+ return [4 /*yield*/, Project.importServicePluginAsync(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError)];
171708
+ case 2:
171709
+ resolvedModule = (_a.sent());
171710
+ if (resolvedModule !== undefined) {
171711
+ return [3 /*break*/, 4];
171712
+ }
171713
+ _a.label = 3;
171714
+ case 3:
171715
+ _i++;
171716
+ return [3 /*break*/, 1];
171717
+ case 4: return [2 /*return*/, { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs }];
171718
+ }
171719
+ });
171720
+ });
171721
+ };
171722
+ /**
171723
+ * Performs the remaining steps of enabling a plugin after its module has been instantiated.
171724
+ */
171725
+ /*@internal*/
171726
+ Project.prototype.endEnablePlugin = function (_a) {
171727
+ var _this = this;
171728
+ var pluginConfigEntry = _a.pluginConfigEntry, pluginConfigOverrides = _a.pluginConfigOverrides, resolvedModule = _a.resolvedModule, errorLogs = _a.errorLogs;
171501
171729
  if (resolvedModule) {
171502
171730
  var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
171503
171731
  if (configurationOverride) {
@@ -171509,10 +171737,13 @@ var ts;
171509
171737
  this.enableProxy(resolvedModule, pluginConfigEntry);
171510
171738
  }
171511
171739
  else {
171512
- ts.forEach(errorLogs, log);
171740
+ ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); });
171513
171741
  this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
171514
171742
  }
171515
171743
  };
171744
+ Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171745
+ this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths, pluginConfigOverrides);
171746
+ };
171516
171747
  Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) {
171517
171748
  try {
171518
171749
  if (typeof pluginModuleFactory !== "function") {
@@ -172164,7 +172395,7 @@ var ts;
172164
172395
  /*@internal*/
172165
172396
  ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
172166
172397
  var host = this.projectService.host;
172167
- if (!host.require) {
172398
+ if (!host.require && !host.importServicePlugin) {
172168
172399
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
172169
172400
  return;
172170
172401
  }
@@ -172183,7 +172414,7 @@ var ts;
172183
172414
  this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
172184
172415
  }
172185
172416
  }
172186
- this.enableGlobalPlugins(options, pluginConfigOverrides);
172417
+ return this.enableGlobalPlugins(options, pluginConfigOverrides);
172187
172418
  };
172188
172419
  /**
172189
172420
  * Get the errors that dont have any file name associated
@@ -175605,6 +175836,147 @@ var ts;
175605
175836
  }
175606
175837
  return false;
175607
175838
  };
175839
+ /*@internal*/
175840
+ ProjectService.prototype.requestEnablePlugin = function (project, pluginConfigEntry, searchPaths, pluginConfigOverrides) {
175841
+ var _a;
175842
+ if (!this.host.importServicePlugin && !this.host.require) {
175843
+ this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
175844
+ return;
175845
+ }
175846
+ this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
175847
+ if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
175848
+ this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
175849
+ return;
175850
+ }
175851
+ // If the host supports dynamic import, begin enabling the plugin asynchronously.
175852
+ if (this.host.importServicePlugin) {
175853
+ var importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides);
175854
+ (_a = this.pendingPluginEnablements) !== null && _a !== void 0 ? _a : (this.pendingPluginEnablements = new ts.Map());
175855
+ var promises = this.pendingPluginEnablements.get(project);
175856
+ if (!promises)
175857
+ this.pendingPluginEnablements.set(project, promises = []);
175858
+ promises.push(importPromise);
175859
+ return;
175860
+ }
175861
+ // Otherwise, load the plugin using `require`
175862
+ project.endEnablePlugin(project.beginEnablePluginSync(pluginConfigEntry, searchPaths, pluginConfigOverrides));
175863
+ };
175864
+ /* @internal */
175865
+ ProjectService.prototype.hasNewPluginEnablementRequests = function () {
175866
+ return !!this.pendingPluginEnablements;
175867
+ };
175868
+ /* @internal */
175869
+ ProjectService.prototype.hasPendingPluginEnablements = function () {
175870
+ return !!this.currentPluginEnablementPromise;
175871
+ };
175872
+ /**
175873
+ * Waits for any ongoing plugin enablement requests to complete.
175874
+ */
175875
+ /* @internal */
175876
+ ProjectService.prototype.waitForPendingPlugins = function () {
175877
+ return __awaiter(this, void 0, void 0, function () {
175878
+ return __generator(this, function (_a) {
175879
+ switch (_a.label) {
175880
+ case 0:
175881
+ if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
175882
+ return [4 /*yield*/, this.currentPluginEnablementPromise];
175883
+ case 1:
175884
+ _a.sent();
175885
+ return [3 /*break*/, 0];
175886
+ case 2: return [2 /*return*/];
175887
+ }
175888
+ });
175889
+ });
175890
+ };
175891
+ /**
175892
+ * Starts enabling any requested plugins without waiting for the result.
175893
+ */
175894
+ /* @internal */
175895
+ ProjectService.prototype.enableRequestedPlugins = function () {
175896
+ if (this.pendingPluginEnablements) {
175897
+ void this.enableRequestedPluginsAsync();
175898
+ }
175899
+ };
175900
+ ProjectService.prototype.enableRequestedPluginsAsync = function () {
175901
+ return __awaiter(this, void 0, void 0, function () {
175902
+ var entries;
175903
+ return __generator(this, function (_a) {
175904
+ switch (_a.label) {
175905
+ case 0:
175906
+ if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
175907
+ // If we're already enabling plugins, wait for any existing operations to complete
175908
+ return [4 /*yield*/, this.waitForPendingPlugins()];
175909
+ case 1:
175910
+ // If we're already enabling plugins, wait for any existing operations to complete
175911
+ _a.sent();
175912
+ _a.label = 2;
175913
+ case 2:
175914
+ // Skip if there are no new plugin enablement requests
175915
+ if (!this.pendingPluginEnablements) {
175916
+ return [2 /*return*/];
175917
+ }
175918
+ entries = ts.arrayFrom(this.pendingPluginEnablements.entries());
175919
+ this.pendingPluginEnablements = undefined;
175920
+ // Start processing the requests, keeping track of the promise for the operation so that
175921
+ // project consumers can potentially wait for the plugins to load.
175922
+ this.currentPluginEnablementPromise = this.enableRequestedPluginsWorker(entries);
175923
+ return [4 /*yield*/, this.currentPluginEnablementPromise];
175924
+ case 3:
175925
+ _a.sent();
175926
+ return [2 /*return*/];
175927
+ }
175928
+ });
175929
+ });
175930
+ };
175931
+ ProjectService.prototype.enableRequestedPluginsWorker = function (pendingPlugins) {
175932
+ return __awaiter(this, void 0, void 0, function () {
175933
+ var _this = this;
175934
+ return __generator(this, function (_a) {
175935
+ switch (_a.label) {
175936
+ case 0:
175937
+ // This should only be called from `enableRequestedPluginsAsync`, which ensures this precondition is met.
175938
+ ts.Debug.assert(this.currentPluginEnablementPromise === undefined);
175939
+ // Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
175940
+ // on a project with many plugins.
175941
+ return [4 /*yield*/, Promise.all(ts.map(pendingPlugins, function (_a) {
175942
+ var project = _a[0], promises = _a[1];
175943
+ return _this.enableRequestedPluginsForProjectAsync(project, promises);
175944
+ }))];
175945
+ case 1:
175946
+ // Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
175947
+ // on a project with many plugins.
175948
+ _a.sent();
175949
+ // Clear the pending operation and notify the client that projects have been updated.
175950
+ this.currentPluginEnablementPromise = undefined;
175951
+ this.sendProjectsUpdatedInBackgroundEvent();
175952
+ return [2 /*return*/];
175953
+ }
175954
+ });
175955
+ });
175956
+ };
175957
+ ProjectService.prototype.enableRequestedPluginsForProjectAsync = function (project, promises) {
175958
+ return __awaiter(this, void 0, void 0, function () {
175959
+ var results, _i, results_1, result;
175960
+ return __generator(this, function (_a) {
175961
+ switch (_a.label) {
175962
+ case 0: return [4 /*yield*/, Promise.all(promises)];
175963
+ case 1:
175964
+ results = _a.sent();
175965
+ if (project.isClosed()) {
175966
+ // project is not alive, so don't enable plugins.
175967
+ return [2 /*return*/];
175968
+ }
175969
+ for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
175970
+ result = results_1[_i];
175971
+ project.endEnablePlugin(result);
175972
+ }
175973
+ // Plugins may have modified external files, so mark the project as dirty.
175974
+ this.delayUpdateProjectGraph(project);
175975
+ return [2 /*return*/];
175976
+ }
175977
+ });
175978
+ });
175979
+ };
175608
175980
  ProjectService.prototype.configurePlugin = function (args) {
175609
175981
  // For any projects that already have the plugin loaded, configure the plugin
175610
175982
  this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); });
@@ -176433,7 +176805,6 @@ var ts;
176433
176805
  server.CommandNames.OrganizeImportsFull,
176434
176806
  server.CommandNames.GetEditsForFileRename,
176435
176807
  server.CommandNames.GetEditsForFileRenameFull,
176436
- server.CommandNames.ConfigurePlugin,
176437
176808
  server.CommandNames.PrepareCallHierarchy,
176438
176809
  server.CommandNames.ProvideCallHierarchyIncomingCalls,
176439
176810
  server.CommandNames.ProvideCallHierarchyOutgoingCalls,
@@ -178701,7 +179072,9 @@ var ts;
178701
179072
  Session.prototype.executeCommand = function (request) {
178702
179073
  var handler = this.handlers.get(request.command);
178703
179074
  if (handler) {
178704
- return this.executeWithRequestId(request.seq, function () { return handler(request); });
179075
+ var response = this.executeWithRequestId(request.seq, function () { return handler(request); });
179076
+ this.projectService.enableRequestedPlugins();
179077
+ return response;
178705
179078
  }
178706
179079
  else {
178707
179080
  this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err);
@@ -179615,6 +179988,8 @@ var ts;
179615
179988
  })(server = ts.server || (ts.server = {}));
179616
179989
  })(ts || (ts = {}));
179617
179990
  /*@internal*/
179991
+ /// <reference lib="dom" />
179992
+ /// <reference lib="webworker.importscripts" />
179618
179993
  var ts;
179619
179994
  (function (ts) {
179620
179995
  var server;
@@ -179720,11 +180095,31 @@ var ts;
179720
180095
  return MainProcessLogger;
179721
180096
  }(BaseLogger));
179722
180097
  server.MainProcessLogger = MainProcessLogger;
180098
+ // Attempt to load `dynamicImport`
180099
+ if (typeof importScripts === "function") {
180100
+ try {
180101
+ // NOTE: importScripts is synchronous
180102
+ importScripts("dynamicImportCompat.js");
180103
+ }
180104
+ catch (_a) {
180105
+ // ignored
180106
+ }
180107
+ }
179723
180108
  function createWebSystem(host, args, getExecutingFilePath) {
180109
+ var _this = this;
179724
180110
  var returnEmptyString = function () { return ""; };
179725
180111
  var getExecutingDirectoryPath = ts.memoize(function () { return ts.memoize(function () { return ts.ensureTrailingDirectorySeparator(ts.getDirectoryPath(getExecutingFilePath())); }); });
179726
180112
  // Later we could map ^memfs:/ to do something special if we want to enable more functionality like module resolution or something like that
179727
180113
  var getWebPath = function (path) { return ts.startsWith(path, ts.directorySeparator) ? path.replace(ts.directorySeparator, getExecutingDirectoryPath()) : undefined; };
180114
+ var dynamicImport = function (id) { return __awaiter(_this, void 0, void 0, function () {
180115
+ return __generator(this, function (_a) {
180116
+ // Use syntactic dynamic import first, if available
180117
+ if (server.dynamicImport) {
180118
+ return [2 /*return*/, server.dynamicImport(id)];
180119
+ }
180120
+ throw new Error("Dynamic import not implemented");
180121
+ });
180122
+ }); };
179728
180123
  return {
179729
180124
  args: args,
179730
180125
  newLine: "\r\n",
@@ -179750,7 +180145,45 @@ var ts;
179750
180145
  setImmediate: function (x) { return setTimeout(x, 0); },
179751
180146
  clearImmediate: function (handle) { return clearTimeout(handle); },
179752
180147
  /* eslint-enable no-restricted-globals */
179753
- require: function () { return ({ module: undefined, error: new Error("Not implemented") }); },
180148
+ importServicePlugin: function (initialDir, moduleName) { return __awaiter(_this, void 0, void 0, function () {
180149
+ var packageRoot, packageJson, packageJsonResponse, e_1, browser, scriptPath, module_1, e_2;
180150
+ return __generator(this, function (_a) {
180151
+ switch (_a.label) {
180152
+ case 0:
180153
+ packageRoot = ts.combinePaths(initialDir, moduleName);
180154
+ _a.label = 1;
180155
+ case 1:
180156
+ _a.trys.push([1, 4, , 5]);
180157
+ return [4 /*yield*/, fetch(ts.combinePaths(packageRoot, "package.json"))];
180158
+ case 2:
180159
+ packageJsonResponse = _a.sent();
180160
+ return [4 /*yield*/, packageJsonResponse.json()];
180161
+ case 3:
180162
+ packageJson = _a.sent();
180163
+ return [3 /*break*/, 5];
180164
+ case 4:
180165
+ e_1 = _a.sent();
180166
+ return [2 /*return*/, { module: undefined, error: new Error("Could not load plugin. Could not load 'package.json'.") }];
180167
+ case 5:
180168
+ browser = packageJson.browser;
180169
+ if (!browser) {
180170
+ return [2 /*return*/, { module: undefined, error: new Error("Could not load plugin. No 'browser' field found in package.json.") }];
180171
+ }
180172
+ scriptPath = ts.combinePaths(packageRoot, browser);
180173
+ _a.label = 6;
180174
+ case 6:
180175
+ _a.trys.push([6, 8, , 9]);
180176
+ return [4 /*yield*/, dynamicImport(scriptPath)];
180177
+ case 7:
180178
+ module_1 = (_a.sent()).default;
180179
+ return [2 /*return*/, { module: module_1, error: undefined }];
180180
+ case 8:
180181
+ e_2 = _a.sent();
180182
+ return [2 /*return*/, { module: undefined, error: e_2 }];
180183
+ case 9: return [2 /*return*/];
180184
+ }
180185
+ });
180186
+ }); },
179754
180187
  exit: ts.notImplemented,
179755
180188
  // Debugging related
179756
180189
  getEnvironmentVariable: returnEmptyString,