typescript 4.8.0-dev.20220614 → 4.8.0-dev.20220615

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.
@@ -91,6 +91,15 @@ var __extends = (this && this.__extends) || (function () {
91
91
  d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
92
92
  };
93
93
  })();
94
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
95
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
96
+ return new (P || (P = Promise))(function (resolve, reject) {
97
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
98
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
99
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
100
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
101
+ });
102
+ };
94
103
  /* @internal */
95
104
  var ts;
96
105
  (function (ts) {
@@ -294,7 +303,7 @@ var ts;
294
303
  // The following is baselined as a literal template type without intervention
295
304
  /** The version of the TypeScript compiler release */
296
305
  // eslint-disable-next-line @typescript-eslint/no-inferrable-types
297
- ts.version = ts.versionMajorMinor + ".0-dev.20220614";
306
+ ts.version = ts.versionMajorMinor + ".0-dev.20220615";
298
307
  /* @internal */
299
308
  var Comparison;
300
309
  (function (Comparison) {
@@ -9156,6 +9165,8 @@ var ts;
9156
9165
  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."),
9157
9166
  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"),
9158
9167
  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'."),
9168
+ _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?"),
9169
+ 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."),
9159
9170
  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}'."),
9160
9171
  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}'."),
9161
9172
  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}'."),
@@ -49387,6 +49398,7 @@ var ts;
49387
49398
  var potentialNewTargetCollisions = [];
49388
49399
  var potentialWeakMapSetCollisions = [];
49389
49400
  var potentialReflectCollisions = [];
49401
+ var potentialUnusedRenamedBindingElementsInTypes = [];
49390
49402
  var awaitedTypeStack = [];
49391
49403
  var diagnostics = ts.createDiagnosticCollection();
49392
49404
  var suggestionDiagnostics = ts.createDiagnosticCollection();
@@ -53894,15 +53906,22 @@ var ts;
53894
53906
  context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
53895
53907
  return parameterNode;
53896
53908
  function cloneBindingName(node) {
53897
- return elideInitializerAndSetEmitFlags(node);
53898
- function elideInitializerAndSetEmitFlags(node) {
53909
+ return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
53910
+ function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
53899
53911
  if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
53900
53912
  trackComputedName(node.expression, context.enclosingDeclaration, context);
53901
53913
  }
53902
- var visited = ts.visitEachChild(node, elideInitializerAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndSetEmitFlags);
53914
+ var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
53903
53915
  if (ts.isBindingElement(visited)) {
53904
- visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
53905
- /*initializer*/ undefined);
53916
+ if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
53917
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
53918
+ /* propertyName*/ undefined, visited.propertyName,
53919
+ /*initializer*/ undefined);
53920
+ }
53921
+ else {
53922
+ visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
53923
+ /*initializer*/ undefined);
53924
+ }
53906
53925
  }
53907
53926
  if (!ts.nodeIsSynthesized(visited)) {
53908
53927
  visited = ts.factory.cloneNode(visited);
@@ -68226,12 +68245,13 @@ var ts;
68226
68245
  * with no call or construct signatures.
68227
68246
  */
68228
68247
  function isObjectTypeWithInferableIndex(type) {
68248
+ var objectFlags = ts.getObjectFlags(type);
68229
68249
  return type.flags & 2097152 /* Intersection */
68230
68250
  ? ts.every(type.types, isObjectTypeWithInferableIndex)
68231
68251
  : !!(type.symbol
68232
68252
  && (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
68233
68253
  && !(type.symbol.flags & 32 /* Class */)
68234
- && !typeHasCallOrConstructSignatures(type)) || !!(ts.getObjectFlags(type) & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
68254
+ && !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
68235
68255
  }
68236
68256
  function createSymbolWithType(source, type) {
68237
68257
  var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
@@ -82830,6 +82850,22 @@ var ts;
82830
82850
  }
82831
82851
  });
82832
82852
  }
82853
+ function checkPotentialUncheckedRenamedBindingElementsInTypes() {
82854
+ var _a;
82855
+ for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
82856
+ var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
82857
+ if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
82858
+ var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
82859
+ ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
82860
+ 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));
82861
+ if (!wrappingDeclaration.type) {
82862
+ // entire parameter does not have type annotation, suggest adding an annotation
82863
+ 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)));
82864
+ }
82865
+ diagnostics.add(diagnostic);
82866
+ }
82867
+ }
82868
+ }
82833
82869
  function bindingNameText(name) {
82834
82870
  switch (name.kind) {
82835
82871
  case 79 /* Identifier */:
@@ -83131,6 +83167,17 @@ var ts;
83131
83167
  }
83132
83168
  }
83133
83169
  if (ts.isBindingElement(node)) {
83170
+ if (node.propertyName &&
83171
+ ts.isIdentifier(node.name) &&
83172
+ ts.isParameterDeclaration(node) &&
83173
+ ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
83174
+ // type F = ({a: string}) => void;
83175
+ // ^^^^^^
83176
+ // variable renaming in function type notation is confusing,
83177
+ // so we forbid it even if noUnusedLocals is not enabled
83178
+ potentialUnusedRenamedBindingElementsInTypes.push(node);
83179
+ return;
83180
+ }
83134
83181
  if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
83135
83182
  checkExternalEmitHelpers(node, 4 /* Rest */);
83136
83183
  }
@@ -86594,6 +86641,7 @@ var ts;
86594
86641
  ts.clear(potentialNewTargetCollisions);
86595
86642
  ts.clear(potentialWeakMapSetCollisions);
86596
86643
  ts.clear(potentialReflectCollisions);
86644
+ ts.clear(potentialUnusedRenamedBindingElementsInTypes);
86597
86645
  ts.forEach(node.statements, checkSourceElement);
86598
86646
  checkSourceElement(node.endOfFileToken);
86599
86647
  checkDeferredNodes(node);
@@ -86609,6 +86657,9 @@ var ts;
86609
86657
  }
86610
86658
  });
86611
86659
  }
86660
+ if (!node.isDeclarationFile) {
86661
+ checkPotentialUncheckedRenamedBindingElementsInTypes();
86662
+ }
86612
86663
  });
86613
86664
  if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
86614
86665
  !node.isDeclarationFile &&
@@ -109350,7 +109401,7 @@ var ts;
109350
109401
  });
109351
109402
  return ret;
109352
109403
  }
109353
- function filterBindingPatternInitializers(name) {
109404
+ function filterBindingPatternInitializersAndRenamings(name) {
109354
109405
  if (name.kind === 79 /* Identifier */) {
109355
109406
  return name;
109356
109407
  }
@@ -109366,7 +109417,12 @@ var ts;
109366
109417
  if (elem.kind === 227 /* OmittedExpression */) {
109367
109418
  return elem;
109368
109419
  }
109369
- return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializers(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109420
+ if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
109421
+ // Unnecessary property renaming is forbidden in types, so remove renaming
109422
+ return factory.updateBindingElement(elem, elem.dotDotDotToken,
109423
+ /* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109424
+ }
109425
+ return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
109370
109426
  }
109371
109427
  }
109372
109428
  function ensureParameter(p, modifierMask, type) {
@@ -109375,7 +109431,7 @@ var ts;
109375
109431
  oldDiag = getSymbolAccessibilityDiagnostic;
109376
109432
  getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
109377
109433
  }
109378
- 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
109434
+ 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
109379
109435
  ensureNoInitializer(p));
109380
109436
  if (!suppressNewDiagnosticContexts) {
109381
109437
  getSymbolAccessibilityDiagnostic = oldDiag;
@@ -117518,6 +117574,7 @@ var ts;
117518
117574
  ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
117519
117575
  ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
117520
117576
  ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
117577
+ ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
117521
117578
  ]);
117522
117579
  /**
117523
117580
  * Determine if source file needs to be re-created even if its text hasn't changed
@@ -170590,6 +170647,38 @@ var ts;
170590
170647
  }
170591
170648
  return result.module;
170592
170649
  };
170650
+ /*@internal*/
170651
+ Project.importServicePluginAsync = function (moduleName, initialDir, host, log, logErrors) {
170652
+ return __awaiter(this, void 0, void 0, function () {
170653
+ var resolvedPath, result, e_1, err;
170654
+ return __generator(this, function (_a) {
170655
+ switch (_a.label) {
170656
+ case 0:
170657
+ ts.Debug.assertIsDefined(host.importServicePlugin);
170658
+ resolvedPath = ts.combinePaths(initialDir, "node_modules");
170659
+ log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
170660
+ _a.label = 1;
170661
+ case 1:
170662
+ _a.trys.push([1, 3, , 4]);
170663
+ return [4 /*yield*/, host.importServicePlugin(resolvedPath, moduleName)];
170664
+ case 2:
170665
+ result = _a.sent();
170666
+ return [3 /*break*/, 4];
170667
+ case 3:
170668
+ e_1 = _a.sent();
170669
+ result = { module: undefined, error: e_1 };
170670
+ return [3 /*break*/, 4];
170671
+ case 4:
170672
+ if (result.error) {
170673
+ err = result.error.stack || result.error.message || JSON.stringify(result.error);
170674
+ (logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err);
170675
+ return [2 /*return*/, undefined];
170676
+ }
170677
+ return [2 /*return*/, result.module];
170678
+ }
170679
+ });
170680
+ });
170681
+ };
170593
170682
  Project.prototype.isKnownTypesPackageName = function (name) {
170594
170683
  return this.typingsCache.isKnownTypesPackageName(name);
170595
170684
  };
@@ -171650,7 +171739,7 @@ var ts;
171650
171739
  };
171651
171740
  Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
171652
171741
  var host = this.projectService.host;
171653
- if (!host.require) {
171742
+ if (!host.require && !host.importServicePlugin) {
171654
171743
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
171655
171744
  return;
171656
171745
  }
@@ -171679,21 +171768,66 @@ var ts;
171679
171768
  }
171680
171769
  }
171681
171770
  };
171682
- Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171771
+ /**
171772
+ * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'.
171773
+ */
171774
+ /*@internal*/
171775
+ Project.prototype.beginEnablePluginSync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171683
171776
  var _this = this;
171684
- this.projectService.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
171685
- if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
171686
- this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
171687
- return;
171688
- }
171689
- var log = function (message) { return _this.projectService.logger.info(message); };
171777
+ ts.Debug.assertIsDefined(this.projectService.host.require);
171690
171778
  var errorLogs;
171779
+ var log = function (message) { return _this.projectService.logger.info(message); };
171691
171780
  var logError = function (message) {
171692
- (errorLogs || (errorLogs = [])).push(message);
171781
+ (errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
171693
171782
  };
171694
171783
  var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
171695
171784
  return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
171696
171785
  });
171786
+ return { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs };
171787
+ };
171788
+ /**
171789
+ * Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`.
171790
+ */
171791
+ /*@internal*/
171792
+ Project.prototype.beginEnablePluginAsync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171793
+ return __awaiter(this, void 0, void 0, function () {
171794
+ var errorLogs, log, logError, resolvedModule, _i, searchPaths_1, searchPath;
171795
+ var _this = this;
171796
+ return __generator(this, function (_a) {
171797
+ switch (_a.label) {
171798
+ case 0:
171799
+ ts.Debug.assertIsDefined(this.projectService.host.importServicePlugin);
171800
+ log = function (message) { return _this.projectService.logger.info(message); };
171801
+ logError = function (message) {
171802
+ (errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
171803
+ };
171804
+ _i = 0, searchPaths_1 = searchPaths;
171805
+ _a.label = 1;
171806
+ case 1:
171807
+ if (!(_i < searchPaths_1.length)) return [3 /*break*/, 4];
171808
+ searchPath = searchPaths_1[_i];
171809
+ return [4 /*yield*/, Project.importServicePluginAsync(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError)];
171810
+ case 2:
171811
+ resolvedModule = (_a.sent());
171812
+ if (resolvedModule !== undefined) {
171813
+ return [3 /*break*/, 4];
171814
+ }
171815
+ _a.label = 3;
171816
+ case 3:
171817
+ _i++;
171818
+ return [3 /*break*/, 1];
171819
+ case 4: return [2 /*return*/, { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs }];
171820
+ }
171821
+ });
171822
+ });
171823
+ };
171824
+ /**
171825
+ * Performs the remaining steps of enabling a plugin after its module has been instantiated.
171826
+ */
171827
+ /*@internal*/
171828
+ Project.prototype.endEnablePlugin = function (_a) {
171829
+ var _this = this;
171830
+ var pluginConfigEntry = _a.pluginConfigEntry, pluginConfigOverrides = _a.pluginConfigOverrides, resolvedModule = _a.resolvedModule, errorLogs = _a.errorLogs;
171697
171831
  if (resolvedModule) {
171698
171832
  var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
171699
171833
  if (configurationOverride) {
@@ -171705,10 +171839,13 @@ var ts;
171705
171839
  this.enableProxy(resolvedModule, pluginConfigEntry);
171706
171840
  }
171707
171841
  else {
171708
- ts.forEach(errorLogs, log);
171842
+ ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); });
171709
171843
  this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
171710
171844
  }
171711
171845
  };
171846
+ Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
171847
+ this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths, pluginConfigOverrides);
171848
+ };
171712
171849
  Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) {
171713
171850
  try {
171714
171851
  if (typeof pluginModuleFactory !== "function") {
@@ -172360,7 +172497,7 @@ var ts;
172360
172497
  /*@internal*/
172361
172498
  ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
172362
172499
  var host = this.projectService.host;
172363
- if (!host.require) {
172500
+ if (!host.require && !host.importServicePlugin) {
172364
172501
  this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
172365
172502
  return;
172366
172503
  }
@@ -172379,7 +172516,7 @@ var ts;
172379
172516
  this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
172380
172517
  }
172381
172518
  }
172382
- this.enableGlobalPlugins(options, pluginConfigOverrides);
172519
+ return this.enableGlobalPlugins(options, pluginConfigOverrides);
172383
172520
  };
172384
172521
  /**
172385
172522
  * Get the errors that dont have any file name associated
@@ -175801,6 +175938,147 @@ var ts;
175801
175938
  }
175802
175939
  return false;
175803
175940
  };
175941
+ /*@internal*/
175942
+ ProjectService.prototype.requestEnablePlugin = function (project, pluginConfigEntry, searchPaths, pluginConfigOverrides) {
175943
+ var _a;
175944
+ if (!this.host.importServicePlugin && !this.host.require) {
175945
+ this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
175946
+ return;
175947
+ }
175948
+ this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
175949
+ if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
175950
+ this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
175951
+ return;
175952
+ }
175953
+ // If the host supports dynamic import, begin enabling the plugin asynchronously.
175954
+ if (this.host.importServicePlugin) {
175955
+ var importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides);
175956
+ (_a = this.pendingPluginEnablements) !== null && _a !== void 0 ? _a : (this.pendingPluginEnablements = new ts.Map());
175957
+ var promises = this.pendingPluginEnablements.get(project);
175958
+ if (!promises)
175959
+ this.pendingPluginEnablements.set(project, promises = []);
175960
+ promises.push(importPromise);
175961
+ return;
175962
+ }
175963
+ // Otherwise, load the plugin using `require`
175964
+ project.endEnablePlugin(project.beginEnablePluginSync(pluginConfigEntry, searchPaths, pluginConfigOverrides));
175965
+ };
175966
+ /* @internal */
175967
+ ProjectService.prototype.hasNewPluginEnablementRequests = function () {
175968
+ return !!this.pendingPluginEnablements;
175969
+ };
175970
+ /* @internal */
175971
+ ProjectService.prototype.hasPendingPluginEnablements = function () {
175972
+ return !!this.currentPluginEnablementPromise;
175973
+ };
175974
+ /**
175975
+ * Waits for any ongoing plugin enablement requests to complete.
175976
+ */
175977
+ /* @internal */
175978
+ ProjectService.prototype.waitForPendingPlugins = function () {
175979
+ return __awaiter(this, void 0, void 0, function () {
175980
+ return __generator(this, function (_a) {
175981
+ switch (_a.label) {
175982
+ case 0:
175983
+ if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
175984
+ return [4 /*yield*/, this.currentPluginEnablementPromise];
175985
+ case 1:
175986
+ _a.sent();
175987
+ return [3 /*break*/, 0];
175988
+ case 2: return [2 /*return*/];
175989
+ }
175990
+ });
175991
+ });
175992
+ };
175993
+ /**
175994
+ * Starts enabling any requested plugins without waiting for the result.
175995
+ */
175996
+ /* @internal */
175997
+ ProjectService.prototype.enableRequestedPlugins = function () {
175998
+ if (this.pendingPluginEnablements) {
175999
+ void this.enableRequestedPluginsAsync();
176000
+ }
176001
+ };
176002
+ ProjectService.prototype.enableRequestedPluginsAsync = function () {
176003
+ return __awaiter(this, void 0, void 0, function () {
176004
+ var entries;
176005
+ return __generator(this, function (_a) {
176006
+ switch (_a.label) {
176007
+ case 0:
176008
+ if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
176009
+ // If we're already enabling plugins, wait for any existing operations to complete
176010
+ return [4 /*yield*/, this.waitForPendingPlugins()];
176011
+ case 1:
176012
+ // If we're already enabling plugins, wait for any existing operations to complete
176013
+ _a.sent();
176014
+ _a.label = 2;
176015
+ case 2:
176016
+ // Skip if there are no new plugin enablement requests
176017
+ if (!this.pendingPluginEnablements) {
176018
+ return [2 /*return*/];
176019
+ }
176020
+ entries = ts.arrayFrom(this.pendingPluginEnablements.entries());
176021
+ this.pendingPluginEnablements = undefined;
176022
+ // Start processing the requests, keeping track of the promise for the operation so that
176023
+ // project consumers can potentially wait for the plugins to load.
176024
+ this.currentPluginEnablementPromise = this.enableRequestedPluginsWorker(entries);
176025
+ return [4 /*yield*/, this.currentPluginEnablementPromise];
176026
+ case 3:
176027
+ _a.sent();
176028
+ return [2 /*return*/];
176029
+ }
176030
+ });
176031
+ });
176032
+ };
176033
+ ProjectService.prototype.enableRequestedPluginsWorker = function (pendingPlugins) {
176034
+ return __awaiter(this, void 0, void 0, function () {
176035
+ var _this = this;
176036
+ return __generator(this, function (_a) {
176037
+ switch (_a.label) {
176038
+ case 0:
176039
+ // This should only be called from `enableRequestedPluginsAsync`, which ensures this precondition is met.
176040
+ ts.Debug.assert(this.currentPluginEnablementPromise === undefined);
176041
+ // Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
176042
+ // on a project with many plugins.
176043
+ return [4 /*yield*/, Promise.all(ts.map(pendingPlugins, function (_a) {
176044
+ var project = _a[0], promises = _a[1];
176045
+ return _this.enableRequestedPluginsForProjectAsync(project, promises);
176046
+ }))];
176047
+ case 1:
176048
+ // Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
176049
+ // on a project with many plugins.
176050
+ _a.sent();
176051
+ // Clear the pending operation and notify the client that projects have been updated.
176052
+ this.currentPluginEnablementPromise = undefined;
176053
+ this.sendProjectsUpdatedInBackgroundEvent();
176054
+ return [2 /*return*/];
176055
+ }
176056
+ });
176057
+ });
176058
+ };
176059
+ ProjectService.prototype.enableRequestedPluginsForProjectAsync = function (project, promises) {
176060
+ return __awaiter(this, void 0, void 0, function () {
176061
+ var results, _i, results_1, result;
176062
+ return __generator(this, function (_a) {
176063
+ switch (_a.label) {
176064
+ case 0: return [4 /*yield*/, Promise.all(promises)];
176065
+ case 1:
176066
+ results = _a.sent();
176067
+ if (project.isClosed()) {
176068
+ // project is not alive, so don't enable plugins.
176069
+ return [2 /*return*/];
176070
+ }
176071
+ for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
176072
+ result = results_1[_i];
176073
+ project.endEnablePlugin(result);
176074
+ }
176075
+ // Plugins may have modified external files, so mark the project as dirty.
176076
+ this.delayUpdateProjectGraph(project);
176077
+ return [2 /*return*/];
176078
+ }
176079
+ });
176080
+ });
176081
+ };
175804
176082
  ProjectService.prototype.configurePlugin = function (args) {
175805
176083
  // For any projects that already have the plugin loaded, configure the plugin
175806
176084
  this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); });
@@ -176629,7 +176907,6 @@ var ts;
176629
176907
  server.CommandNames.OrganizeImportsFull,
176630
176908
  server.CommandNames.GetEditsForFileRename,
176631
176909
  server.CommandNames.GetEditsForFileRenameFull,
176632
- server.CommandNames.ConfigurePlugin,
176633
176910
  server.CommandNames.PrepareCallHierarchy,
176634
176911
  server.CommandNames.ProvideCallHierarchyIncomingCalls,
176635
176912
  server.CommandNames.ProvideCallHierarchyOutgoingCalls,
@@ -178897,7 +179174,9 @@ var ts;
178897
179174
  Session.prototype.executeCommand = function (request) {
178898
179175
  var handler = this.handlers.get(request.command);
178899
179176
  if (handler) {
178900
- return this.executeWithRequestId(request.seq, function () { return handler(request); });
179177
+ var response = this.executeWithRequestId(request.seq, function () { return handler(request); });
179178
+ this.projectService.enableRequestedPlugins();
179179
+ return response;
178901
179180
  }
178902
179181
  else {
178903
179182
  this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err);