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/dynamicImportCompat.js +25 -0
- package/lib/tsc.js +68 -16
- package/lib/tsserver.js +466 -33
- package/lib/tsserverlibrary.d.ts +10 -2
- package/lib/tsserverlibrary.js +405 -32
- package/lib/typescript.js +160 -18
- package/lib/typescriptServices.js +160 -18
- package/lib/typingsInstaller.js +78 -17
- package/package.json +2 -1
package/lib/tsserverlibrary.js
CHANGED
|
@@ -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.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220616";
|
|
298
307
|
/* @internal */
|
|
299
308
|
var Comparison;
|
|
300
309
|
(function (Comparison) {
|
|
@@ -8668,9 +8677,11 @@ var ts;
|
|
|
8668
8677
|
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),
|
|
8669
8678
|
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."),
|
|
8670
8679
|
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."),
|
|
8671
|
-
|
|
8680
|
+
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."),
|
|
8672
8681
|
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."),
|
|
8673
8682
|
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."),
|
|
8683
|
+
Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
|
|
8684
|
+
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"),
|
|
8674
8685
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8675
8686
|
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."),
|
|
8676
8687
|
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."),
|
|
@@ -9156,6 +9167,8 @@ var ts;
|
|
|
9156
9167
|
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
9168
|
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
9169
|
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'."),
|
|
9170
|
+
_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?"),
|
|
9171
|
+
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
9172
|
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
9173
|
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
9174
|
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}'."),
|
|
@@ -35970,10 +35983,11 @@ var ts;
|
|
|
35970
35983
|
}
|
|
35971
35984
|
nextToken();
|
|
35972
35985
|
var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
|
|
35973
|
-
if (
|
|
35986
|
+
if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
|
|
35974
35987
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35975
35988
|
return undefined;
|
|
35976
35989
|
}
|
|
35990
|
+
nextToken();
|
|
35977
35991
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35978
35992
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35979
35993
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -49387,6 +49401,7 @@ var ts;
|
|
|
49387
49401
|
var potentialNewTargetCollisions = [];
|
|
49388
49402
|
var potentialWeakMapSetCollisions = [];
|
|
49389
49403
|
var potentialReflectCollisions = [];
|
|
49404
|
+
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
49390
49405
|
var awaitedTypeStack = [];
|
|
49391
49406
|
var diagnostics = ts.createDiagnosticCollection();
|
|
49392
49407
|
var suggestionDiagnostics = ts.createDiagnosticCollection();
|
|
@@ -52722,6 +52737,9 @@ var ts;
|
|
|
52722
52737
|
if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
|
|
52723
52738
|
return { accessibility: 0 /* Accessible */ };
|
|
52724
52739
|
}
|
|
52740
|
+
if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
|
|
52741
|
+
return { accessibility: 0 /* Accessible */ };
|
|
52742
|
+
}
|
|
52725
52743
|
// Verify if the symbol is accessible
|
|
52726
52744
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
52727
52745
|
accessibility: 1 /* NotAccessible */,
|
|
@@ -53894,15 +53912,22 @@ var ts;
|
|
|
53894
53912
|
context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
|
|
53895
53913
|
return parameterNode;
|
|
53896
53914
|
function cloneBindingName(node) {
|
|
53897
|
-
return
|
|
53898
|
-
function
|
|
53915
|
+
return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
|
|
53916
|
+
function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
|
|
53899
53917
|
if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
|
|
53900
53918
|
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
53901
53919
|
}
|
|
53902
|
-
var visited = ts.visitEachChild(node,
|
|
53920
|
+
var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
|
|
53903
53921
|
if (ts.isBindingElement(visited)) {
|
|
53904
|
-
visited
|
|
53905
|
-
|
|
53922
|
+
if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
|
|
53923
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
|
|
53924
|
+
/* propertyName*/ undefined, visited.propertyName,
|
|
53925
|
+
/*initializer*/ undefined);
|
|
53926
|
+
}
|
|
53927
|
+
else {
|
|
53928
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
|
|
53929
|
+
/*initializer*/ undefined);
|
|
53930
|
+
}
|
|
53906
53931
|
}
|
|
53907
53932
|
if (!ts.nodeIsSynthesized(visited)) {
|
|
53908
53933
|
visited = ts.factory.cloneNode(visited);
|
|
@@ -65112,7 +65137,7 @@ var ts;
|
|
|
65112
65137
|
return true;
|
|
65113
65138
|
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
65114
65139
|
return true;
|
|
65115
|
-
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
|
|
65140
|
+
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */)))
|
|
65116
65141
|
return true;
|
|
65117
65142
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
65118
65143
|
if (s & 1 /* Any */)
|
|
@@ -65675,8 +65700,13 @@ var ts;
|
|
|
65675
65700
|
return;
|
|
65676
65701
|
}
|
|
65677
65702
|
reportRelationError(headMessage, source, target);
|
|
65678
|
-
if (
|
|
65679
|
-
|
|
65703
|
+
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)) {
|
|
65704
|
+
var syntheticParam = cloneTypeParameter(source);
|
|
65705
|
+
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
|
|
65706
|
+
if (hasNonCircularBaseConstraint(syntheticParam)) {
|
|
65707
|
+
var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
|
|
65708
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
|
|
65709
|
+
}
|
|
65680
65710
|
}
|
|
65681
65711
|
}
|
|
65682
65712
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
@@ -65815,7 +65845,7 @@ var ts;
|
|
|
65815
65845
|
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
65816
65846
|
}
|
|
65817
65847
|
if (target.flags & 2097152 /* Intersection */) {
|
|
65818
|
-
return typeRelatedToEachType(
|
|
65848
|
+
return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */);
|
|
65819
65849
|
}
|
|
65820
65850
|
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
65821
65851
|
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
@@ -68226,12 +68256,13 @@ var ts;
|
|
|
68226
68256
|
* with no call or construct signatures.
|
|
68227
68257
|
*/
|
|
68228
68258
|
function isObjectTypeWithInferableIndex(type) {
|
|
68259
|
+
var objectFlags = ts.getObjectFlags(type);
|
|
68229
68260
|
return type.flags & 2097152 /* Intersection */
|
|
68230
68261
|
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
68231
68262
|
: !!(type.symbol
|
|
68232
68263
|
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
68233
68264
|
&& !(type.symbol.flags & 32 /* Class */)
|
|
68234
|
-
&& !typeHasCallOrConstructSignatures(type)) || !!(
|
|
68265
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
68235
68266
|
}
|
|
68236
68267
|
function createSymbolWithType(source, type) {
|
|
68237
68268
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -82830,6 +82861,22 @@ var ts;
|
|
|
82830
82861
|
}
|
|
82831
82862
|
});
|
|
82832
82863
|
}
|
|
82864
|
+
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
82865
|
+
var _a;
|
|
82866
|
+
for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
|
|
82867
|
+
var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
|
|
82868
|
+
if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
|
|
82869
|
+
var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
|
|
82870
|
+
ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
|
|
82871
|
+
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));
|
|
82872
|
+
if (!wrappingDeclaration.type) {
|
|
82873
|
+
// entire parameter does not have type annotation, suggest adding an annotation
|
|
82874
|
+
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)));
|
|
82875
|
+
}
|
|
82876
|
+
diagnostics.add(diagnostic);
|
|
82877
|
+
}
|
|
82878
|
+
}
|
|
82879
|
+
}
|
|
82833
82880
|
function bindingNameText(name) {
|
|
82834
82881
|
switch (name.kind) {
|
|
82835
82882
|
case 79 /* Identifier */:
|
|
@@ -83131,6 +83178,17 @@ var ts;
|
|
|
83131
83178
|
}
|
|
83132
83179
|
}
|
|
83133
83180
|
if (ts.isBindingElement(node)) {
|
|
83181
|
+
if (node.propertyName &&
|
|
83182
|
+
ts.isIdentifier(node.name) &&
|
|
83183
|
+
ts.isParameterDeclaration(node) &&
|
|
83184
|
+
ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
|
|
83185
|
+
// type F = ({a: string}) => void;
|
|
83186
|
+
// ^^^^^^
|
|
83187
|
+
// variable renaming in function type notation is confusing,
|
|
83188
|
+
// so we forbid it even if noUnusedLocals is not enabled
|
|
83189
|
+
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
83190
|
+
return;
|
|
83191
|
+
}
|
|
83134
83192
|
if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
|
|
83135
83193
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
83136
83194
|
}
|
|
@@ -86594,6 +86652,7 @@ var ts;
|
|
|
86594
86652
|
ts.clear(potentialNewTargetCollisions);
|
|
86595
86653
|
ts.clear(potentialWeakMapSetCollisions);
|
|
86596
86654
|
ts.clear(potentialReflectCollisions);
|
|
86655
|
+
ts.clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
86597
86656
|
ts.forEach(node.statements, checkSourceElement);
|
|
86598
86657
|
checkSourceElement(node.endOfFileToken);
|
|
86599
86658
|
checkDeferredNodes(node);
|
|
@@ -86609,6 +86668,9 @@ var ts;
|
|
|
86609
86668
|
}
|
|
86610
86669
|
});
|
|
86611
86670
|
}
|
|
86671
|
+
if (!node.isDeclarationFile) {
|
|
86672
|
+
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
86673
|
+
}
|
|
86612
86674
|
});
|
|
86613
86675
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
86614
86676
|
!node.isDeclarationFile &&
|
|
@@ -109350,7 +109412,7 @@ var ts;
|
|
|
109350
109412
|
});
|
|
109351
109413
|
return ret;
|
|
109352
109414
|
}
|
|
109353
|
-
function
|
|
109415
|
+
function filterBindingPatternInitializersAndRenamings(name) {
|
|
109354
109416
|
if (name.kind === 79 /* Identifier */) {
|
|
109355
109417
|
return name;
|
|
109356
109418
|
}
|
|
@@ -109366,7 +109428,12 @@ var ts;
|
|
|
109366
109428
|
if (elem.kind === 227 /* OmittedExpression */) {
|
|
109367
109429
|
return elem;
|
|
109368
109430
|
}
|
|
109369
|
-
|
|
109431
|
+
if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
|
|
109432
|
+
// Unnecessary property renaming is forbidden in types, so remove renaming
|
|
109433
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken,
|
|
109434
|
+
/* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109435
|
+
}
|
|
109436
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109370
109437
|
}
|
|
109371
109438
|
}
|
|
109372
109439
|
function ensureParameter(p, modifierMask, type) {
|
|
@@ -109375,7 +109442,7 @@ var ts;
|
|
|
109375
109442
|
oldDiag = getSymbolAccessibilityDiagnostic;
|
|
109376
109443
|
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
|
|
109377
109444
|
}
|
|
109378
|
-
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken,
|
|
109445
|
+
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
109446
|
ensureNoInitializer(p));
|
|
109380
109447
|
if (!suppressNewDiagnosticContexts) {
|
|
109381
109448
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
@@ -117518,6 +117585,7 @@ var ts;
|
|
|
117518
117585
|
ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
|
117519
117586
|
ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
|
|
117520
117587
|
ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
|
|
117588
|
+
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
117521
117589
|
]);
|
|
117522
117590
|
/**
|
|
117523
117591
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
@@ -122652,9 +122720,11 @@ var ts;
|
|
|
122652
122720
|
}
|
|
122653
122721
|
function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
|
|
122654
122722
|
ts.Debug.assert(!!resolution.refCount);
|
|
122723
|
+
var affectingLocations = resolution.affectingLocations;
|
|
122724
|
+
if (!affectingLocations.length)
|
|
122725
|
+
return;
|
|
122655
122726
|
if (addToResolutionsWithOnlyAffectingLocations)
|
|
122656
122727
|
resolutionsWithOnlyAffectingLocations.push(resolution);
|
|
122657
|
-
var affectingLocations = resolution.affectingLocations;
|
|
122658
122728
|
// Watch package json
|
|
122659
122729
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
122660
122730
|
var affectingLocation = affectingLocations_1[_i];
|
|
@@ -145770,7 +145840,7 @@ var ts;
|
|
|
145770
145840
|
return type.symbol && (type.symbol.flags & 1536 /* Module */);
|
|
145771
145841
|
}
|
|
145772
145842
|
function visitVariableLikeDeclaration(decl) {
|
|
145773
|
-
if (!decl.initializer || ts.isBindingPattern(decl.name)) {
|
|
145843
|
+
if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
|
|
145774
145844
|
return;
|
|
145775
145845
|
}
|
|
145776
145846
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
|
|
@@ -145898,6 +145968,9 @@ var ts;
|
|
|
145898
145968
|
}
|
|
145899
145969
|
for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
|
|
145900
145970
|
var param = node.parameters[i];
|
|
145971
|
+
if (!isHintableDeclaration(param)) {
|
|
145972
|
+
continue;
|
|
145973
|
+
}
|
|
145901
145974
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
|
|
145902
145975
|
if (effectiveTypeAnnotation) {
|
|
145903
145976
|
continue;
|
|
@@ -145939,6 +146012,13 @@ var ts;
|
|
|
145939
146012
|
function isUndefined(name) {
|
|
145940
146013
|
return name === "undefined";
|
|
145941
146014
|
}
|
|
146015
|
+
function isHintableDeclaration(node) {
|
|
146016
|
+
if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
|
|
146017
|
+
var initializer = ts.skipParentheses(node.initializer);
|
|
146018
|
+
return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
|
|
146019
|
+
}
|
|
146020
|
+
return true;
|
|
146021
|
+
}
|
|
145942
146022
|
}
|
|
145943
146023
|
InlayHints.provideInlayHints = provideInlayHints;
|
|
145944
146024
|
})(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
|
|
@@ -155377,6 +155457,77 @@ var ts;
|
|
|
155377
155457
|
})(ts || (ts = {}));
|
|
155378
155458
|
/* @internal */
|
|
155379
155459
|
var ts;
|
|
155460
|
+
(function (ts) {
|
|
155461
|
+
var codefix;
|
|
155462
|
+
(function (codefix) {
|
|
155463
|
+
var fixId = "addMissingConstraint";
|
|
155464
|
+
var errorCodes = [
|
|
155465
|
+
// We want errors this could be attached to:
|
|
155466
|
+
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
155467
|
+
ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
155468
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
|
|
155469
|
+
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,
|
|
155470
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
155471
|
+
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,
|
|
155472
|
+
ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
|
|
155473
|
+
ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
|
|
155474
|
+
ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
|
|
155475
|
+
];
|
|
155476
|
+
codefix.registerCodeFix({
|
|
155477
|
+
errorCodes: errorCodes,
|
|
155478
|
+
getCodeActions: function (context) {
|
|
155479
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155480
|
+
var related = getDiagnosticRelatedInfo(program, sourceFile, span);
|
|
155481
|
+
if (!related) {
|
|
155482
|
+
return;
|
|
155483
|
+
}
|
|
155484
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155485
|
+
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155486
|
+
},
|
|
155487
|
+
fixIds: [fixId],
|
|
155488
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
155489
|
+
var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
|
|
155490
|
+
if (!info)
|
|
155491
|
+
return;
|
|
155492
|
+
return addMissingConstraint(changes, info);
|
|
155493
|
+
}); },
|
|
155494
|
+
});
|
|
155495
|
+
function getDiagnosticRelatedInfo(program, sourceFile, span) {
|
|
155496
|
+
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155497
|
+
if (!diag || !diag.relatedInformation)
|
|
155498
|
+
return;
|
|
155499
|
+
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155500
|
+
if (!related)
|
|
155501
|
+
return;
|
|
155502
|
+
return related;
|
|
155503
|
+
}
|
|
155504
|
+
function addMissingConstraint(changes, related) {
|
|
155505
|
+
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155506
|
+
if (!decl)
|
|
155507
|
+
return;
|
|
155508
|
+
if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) {
|
|
155509
|
+
decl = decl.parent;
|
|
155510
|
+
}
|
|
155511
|
+
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
155512
|
+
return; // should only issue fix on type parameters written using `extends`
|
|
155513
|
+
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
155514
|
+
if (!newConstraint)
|
|
155515
|
+
return;
|
|
155516
|
+
var newConstraintText = newConstraint[1];
|
|
155517
|
+
changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
|
|
155518
|
+
}
|
|
155519
|
+
function findAncestorMatchingSpan(sourceFile, span) {
|
|
155520
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155521
|
+
var end = ts.textSpanEnd(span);
|
|
155522
|
+
while (token.end < end) {
|
|
155523
|
+
token = token.parent;
|
|
155524
|
+
}
|
|
155525
|
+
return token;
|
|
155526
|
+
}
|
|
155527
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
155528
|
+
})(ts || (ts = {}));
|
|
155529
|
+
/* @internal */
|
|
155530
|
+
var ts;
|
|
155380
155531
|
(function (ts) {
|
|
155381
155532
|
var codefix;
|
|
155382
155533
|
(function (codefix) {
|
|
@@ -170588,6 +170739,38 @@ var ts;
|
|
|
170588
170739
|
}
|
|
170589
170740
|
return result.module;
|
|
170590
170741
|
};
|
|
170742
|
+
/*@internal*/
|
|
170743
|
+
Project.importServicePluginAsync = function (moduleName, initialDir, host, log, logErrors) {
|
|
170744
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170745
|
+
var resolvedPath, result, e_1, err;
|
|
170746
|
+
return __generator(this, function (_a) {
|
|
170747
|
+
switch (_a.label) {
|
|
170748
|
+
case 0:
|
|
170749
|
+
ts.Debug.assertIsDefined(host.importServicePlugin);
|
|
170750
|
+
resolvedPath = ts.combinePaths(initialDir, "node_modules");
|
|
170751
|
+
log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
|
|
170752
|
+
_a.label = 1;
|
|
170753
|
+
case 1:
|
|
170754
|
+
_a.trys.push([1, 3, , 4]);
|
|
170755
|
+
return [4 /*yield*/, host.importServicePlugin(resolvedPath, moduleName)];
|
|
170756
|
+
case 2:
|
|
170757
|
+
result = _a.sent();
|
|
170758
|
+
return [3 /*break*/, 4];
|
|
170759
|
+
case 3:
|
|
170760
|
+
e_1 = _a.sent();
|
|
170761
|
+
result = { module: undefined, error: e_1 };
|
|
170762
|
+
return [3 /*break*/, 4];
|
|
170763
|
+
case 4:
|
|
170764
|
+
if (result.error) {
|
|
170765
|
+
err = result.error.stack || result.error.message || JSON.stringify(result.error);
|
|
170766
|
+
(logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err);
|
|
170767
|
+
return [2 /*return*/, undefined];
|
|
170768
|
+
}
|
|
170769
|
+
return [2 /*return*/, result.module];
|
|
170770
|
+
}
|
|
170771
|
+
});
|
|
170772
|
+
});
|
|
170773
|
+
};
|
|
170591
170774
|
Project.prototype.isKnownTypesPackageName = function (name) {
|
|
170592
170775
|
return this.typingsCache.isKnownTypesPackageName(name);
|
|
170593
170776
|
};
|
|
@@ -171648,7 +171831,7 @@ var ts;
|
|
|
171648
171831
|
};
|
|
171649
171832
|
Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
|
|
171650
171833
|
var host = this.projectService.host;
|
|
171651
|
-
if (!host.require) {
|
|
171834
|
+
if (!host.require && !host.importServicePlugin) {
|
|
171652
171835
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
171653
171836
|
return;
|
|
171654
171837
|
}
|
|
@@ -171677,21 +171860,66 @@ var ts;
|
|
|
171677
171860
|
}
|
|
171678
171861
|
}
|
|
171679
171862
|
};
|
|
171680
|
-
|
|
171863
|
+
/**
|
|
171864
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'.
|
|
171865
|
+
*/
|
|
171866
|
+
/*@internal*/
|
|
171867
|
+
Project.prototype.beginEnablePluginSync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171681
171868
|
var _this = this;
|
|
171682
|
-
this.projectService.
|
|
171683
|
-
if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
|
|
171684
|
-
this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
|
|
171685
|
-
return;
|
|
171686
|
-
}
|
|
171687
|
-
var log = function (message) { return _this.projectService.logger.info(message); };
|
|
171869
|
+
ts.Debug.assertIsDefined(this.projectService.host.require);
|
|
171688
171870
|
var errorLogs;
|
|
171871
|
+
var log = function (message) { return _this.projectService.logger.info(message); };
|
|
171689
171872
|
var logError = function (message) {
|
|
171690
|
-
(errorLogs
|
|
171873
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171691
171874
|
};
|
|
171692
171875
|
var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
|
|
171693
171876
|
return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
|
|
171694
171877
|
});
|
|
171878
|
+
return { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs };
|
|
171879
|
+
};
|
|
171880
|
+
/**
|
|
171881
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`.
|
|
171882
|
+
*/
|
|
171883
|
+
/*@internal*/
|
|
171884
|
+
Project.prototype.beginEnablePluginAsync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171885
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171886
|
+
var errorLogs, log, logError, resolvedModule, _i, searchPaths_1, searchPath;
|
|
171887
|
+
var _this = this;
|
|
171888
|
+
return __generator(this, function (_a) {
|
|
171889
|
+
switch (_a.label) {
|
|
171890
|
+
case 0:
|
|
171891
|
+
ts.Debug.assertIsDefined(this.projectService.host.importServicePlugin);
|
|
171892
|
+
log = function (message) { return _this.projectService.logger.info(message); };
|
|
171893
|
+
logError = function (message) {
|
|
171894
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171895
|
+
};
|
|
171896
|
+
_i = 0, searchPaths_1 = searchPaths;
|
|
171897
|
+
_a.label = 1;
|
|
171898
|
+
case 1:
|
|
171899
|
+
if (!(_i < searchPaths_1.length)) return [3 /*break*/, 4];
|
|
171900
|
+
searchPath = searchPaths_1[_i];
|
|
171901
|
+
return [4 /*yield*/, Project.importServicePluginAsync(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError)];
|
|
171902
|
+
case 2:
|
|
171903
|
+
resolvedModule = (_a.sent());
|
|
171904
|
+
if (resolvedModule !== undefined) {
|
|
171905
|
+
return [3 /*break*/, 4];
|
|
171906
|
+
}
|
|
171907
|
+
_a.label = 3;
|
|
171908
|
+
case 3:
|
|
171909
|
+
_i++;
|
|
171910
|
+
return [3 /*break*/, 1];
|
|
171911
|
+
case 4: return [2 /*return*/, { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs }];
|
|
171912
|
+
}
|
|
171913
|
+
});
|
|
171914
|
+
});
|
|
171915
|
+
};
|
|
171916
|
+
/**
|
|
171917
|
+
* Performs the remaining steps of enabling a plugin after its module has been instantiated.
|
|
171918
|
+
*/
|
|
171919
|
+
/*@internal*/
|
|
171920
|
+
Project.prototype.endEnablePlugin = function (_a) {
|
|
171921
|
+
var _this = this;
|
|
171922
|
+
var pluginConfigEntry = _a.pluginConfigEntry, pluginConfigOverrides = _a.pluginConfigOverrides, resolvedModule = _a.resolvedModule, errorLogs = _a.errorLogs;
|
|
171695
171923
|
if (resolvedModule) {
|
|
171696
171924
|
var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
|
|
171697
171925
|
if (configurationOverride) {
|
|
@@ -171703,10 +171931,13 @@ var ts;
|
|
|
171703
171931
|
this.enableProxy(resolvedModule, pluginConfigEntry);
|
|
171704
171932
|
}
|
|
171705
171933
|
else {
|
|
171706
|
-
ts.forEach(errorLogs,
|
|
171934
|
+
ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); });
|
|
171707
171935
|
this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
|
|
171708
171936
|
}
|
|
171709
171937
|
};
|
|
171938
|
+
Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171939
|
+
this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
171940
|
+
};
|
|
171710
171941
|
Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) {
|
|
171711
171942
|
try {
|
|
171712
171943
|
if (typeof pluginModuleFactory !== "function") {
|
|
@@ -172358,7 +172589,7 @@ var ts;
|
|
|
172358
172589
|
/*@internal*/
|
|
172359
172590
|
ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
|
|
172360
172591
|
var host = this.projectService.host;
|
|
172361
|
-
if (!host.require) {
|
|
172592
|
+
if (!host.require && !host.importServicePlugin) {
|
|
172362
172593
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
172363
172594
|
return;
|
|
172364
172595
|
}
|
|
@@ -172377,7 +172608,7 @@ var ts;
|
|
|
172377
172608
|
this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
172378
172609
|
}
|
|
172379
172610
|
}
|
|
172380
|
-
this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172611
|
+
return this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172381
172612
|
};
|
|
172382
172613
|
/**
|
|
172383
172614
|
* Get the errors that dont have any file name associated
|
|
@@ -175799,6 +176030,147 @@ var ts;
|
|
|
175799
176030
|
}
|
|
175800
176031
|
return false;
|
|
175801
176032
|
};
|
|
176033
|
+
/*@internal*/
|
|
176034
|
+
ProjectService.prototype.requestEnablePlugin = function (project, pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
176035
|
+
var _a;
|
|
176036
|
+
if (!this.host.importServicePlugin && !this.host.require) {
|
|
176037
|
+
this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
176038
|
+
return;
|
|
176039
|
+
}
|
|
176040
|
+
this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
|
|
176041
|
+
if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
|
|
176042
|
+
this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
|
|
176043
|
+
return;
|
|
176044
|
+
}
|
|
176045
|
+
// If the host supports dynamic import, begin enabling the plugin asynchronously.
|
|
176046
|
+
if (this.host.importServicePlugin) {
|
|
176047
|
+
var importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
176048
|
+
(_a = this.pendingPluginEnablements) !== null && _a !== void 0 ? _a : (this.pendingPluginEnablements = new ts.Map());
|
|
176049
|
+
var promises = this.pendingPluginEnablements.get(project);
|
|
176050
|
+
if (!promises)
|
|
176051
|
+
this.pendingPluginEnablements.set(project, promises = []);
|
|
176052
|
+
promises.push(importPromise);
|
|
176053
|
+
return;
|
|
176054
|
+
}
|
|
176055
|
+
// Otherwise, load the plugin using `require`
|
|
176056
|
+
project.endEnablePlugin(project.beginEnablePluginSync(pluginConfigEntry, searchPaths, pluginConfigOverrides));
|
|
176057
|
+
};
|
|
176058
|
+
/* @internal */
|
|
176059
|
+
ProjectService.prototype.hasNewPluginEnablementRequests = function () {
|
|
176060
|
+
return !!this.pendingPluginEnablements;
|
|
176061
|
+
};
|
|
176062
|
+
/* @internal */
|
|
176063
|
+
ProjectService.prototype.hasPendingPluginEnablements = function () {
|
|
176064
|
+
return !!this.currentPluginEnablementPromise;
|
|
176065
|
+
};
|
|
176066
|
+
/**
|
|
176067
|
+
* Waits for any ongoing plugin enablement requests to complete.
|
|
176068
|
+
*/
|
|
176069
|
+
/* @internal */
|
|
176070
|
+
ProjectService.prototype.waitForPendingPlugins = function () {
|
|
176071
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176072
|
+
return __generator(this, function (_a) {
|
|
176073
|
+
switch (_a.label) {
|
|
176074
|
+
case 0:
|
|
176075
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
176076
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
176077
|
+
case 1:
|
|
176078
|
+
_a.sent();
|
|
176079
|
+
return [3 /*break*/, 0];
|
|
176080
|
+
case 2: return [2 /*return*/];
|
|
176081
|
+
}
|
|
176082
|
+
});
|
|
176083
|
+
});
|
|
176084
|
+
};
|
|
176085
|
+
/**
|
|
176086
|
+
* Starts enabling any requested plugins without waiting for the result.
|
|
176087
|
+
*/
|
|
176088
|
+
/* @internal */
|
|
176089
|
+
ProjectService.prototype.enableRequestedPlugins = function () {
|
|
176090
|
+
if (this.pendingPluginEnablements) {
|
|
176091
|
+
void this.enableRequestedPluginsAsync();
|
|
176092
|
+
}
|
|
176093
|
+
};
|
|
176094
|
+
ProjectService.prototype.enableRequestedPluginsAsync = function () {
|
|
176095
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176096
|
+
var entries;
|
|
176097
|
+
return __generator(this, function (_a) {
|
|
176098
|
+
switch (_a.label) {
|
|
176099
|
+
case 0:
|
|
176100
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
176101
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
176102
|
+
return [4 /*yield*/, this.waitForPendingPlugins()];
|
|
176103
|
+
case 1:
|
|
176104
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
176105
|
+
_a.sent();
|
|
176106
|
+
_a.label = 2;
|
|
176107
|
+
case 2:
|
|
176108
|
+
// Skip if there are no new plugin enablement requests
|
|
176109
|
+
if (!this.pendingPluginEnablements) {
|
|
176110
|
+
return [2 /*return*/];
|
|
176111
|
+
}
|
|
176112
|
+
entries = ts.arrayFrom(this.pendingPluginEnablements.entries());
|
|
176113
|
+
this.pendingPluginEnablements = undefined;
|
|
176114
|
+
// Start processing the requests, keeping track of the promise for the operation so that
|
|
176115
|
+
// project consumers can potentially wait for the plugins to load.
|
|
176116
|
+
this.currentPluginEnablementPromise = this.enableRequestedPluginsWorker(entries);
|
|
176117
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
176118
|
+
case 3:
|
|
176119
|
+
_a.sent();
|
|
176120
|
+
return [2 /*return*/];
|
|
176121
|
+
}
|
|
176122
|
+
});
|
|
176123
|
+
});
|
|
176124
|
+
};
|
|
176125
|
+
ProjectService.prototype.enableRequestedPluginsWorker = function (pendingPlugins) {
|
|
176126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176127
|
+
var _this = this;
|
|
176128
|
+
return __generator(this, function (_a) {
|
|
176129
|
+
switch (_a.label) {
|
|
176130
|
+
case 0:
|
|
176131
|
+
// This should only be called from `enableRequestedPluginsAsync`, which ensures this precondition is met.
|
|
176132
|
+
ts.Debug.assert(this.currentPluginEnablementPromise === undefined);
|
|
176133
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
176134
|
+
// on a project with many plugins.
|
|
176135
|
+
return [4 /*yield*/, Promise.all(ts.map(pendingPlugins, function (_a) {
|
|
176136
|
+
var project = _a[0], promises = _a[1];
|
|
176137
|
+
return _this.enableRequestedPluginsForProjectAsync(project, promises);
|
|
176138
|
+
}))];
|
|
176139
|
+
case 1:
|
|
176140
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
176141
|
+
// on a project with many plugins.
|
|
176142
|
+
_a.sent();
|
|
176143
|
+
// Clear the pending operation and notify the client that projects have been updated.
|
|
176144
|
+
this.currentPluginEnablementPromise = undefined;
|
|
176145
|
+
this.sendProjectsUpdatedInBackgroundEvent();
|
|
176146
|
+
return [2 /*return*/];
|
|
176147
|
+
}
|
|
176148
|
+
});
|
|
176149
|
+
});
|
|
176150
|
+
};
|
|
176151
|
+
ProjectService.prototype.enableRequestedPluginsForProjectAsync = function (project, promises) {
|
|
176152
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176153
|
+
var results, _i, results_1, result;
|
|
176154
|
+
return __generator(this, function (_a) {
|
|
176155
|
+
switch (_a.label) {
|
|
176156
|
+
case 0: return [4 /*yield*/, Promise.all(promises)];
|
|
176157
|
+
case 1:
|
|
176158
|
+
results = _a.sent();
|
|
176159
|
+
if (project.isClosed()) {
|
|
176160
|
+
// project is not alive, so don't enable plugins.
|
|
176161
|
+
return [2 /*return*/];
|
|
176162
|
+
}
|
|
176163
|
+
for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
|
|
176164
|
+
result = results_1[_i];
|
|
176165
|
+
project.endEnablePlugin(result);
|
|
176166
|
+
}
|
|
176167
|
+
// Plugins may have modified external files, so mark the project as dirty.
|
|
176168
|
+
this.delayUpdateProjectGraph(project);
|
|
176169
|
+
return [2 /*return*/];
|
|
176170
|
+
}
|
|
176171
|
+
});
|
|
176172
|
+
});
|
|
176173
|
+
};
|
|
175802
176174
|
ProjectService.prototype.configurePlugin = function (args) {
|
|
175803
176175
|
// For any projects that already have the plugin loaded, configure the plugin
|
|
175804
176176
|
this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); });
|
|
@@ -176627,7 +176999,6 @@ var ts;
|
|
|
176627
176999
|
server.CommandNames.OrganizeImportsFull,
|
|
176628
177000
|
server.CommandNames.GetEditsForFileRename,
|
|
176629
177001
|
server.CommandNames.GetEditsForFileRenameFull,
|
|
176630
|
-
server.CommandNames.ConfigurePlugin,
|
|
176631
177002
|
server.CommandNames.PrepareCallHierarchy,
|
|
176632
177003
|
server.CommandNames.ProvideCallHierarchyIncomingCalls,
|
|
176633
177004
|
server.CommandNames.ProvideCallHierarchyOutgoingCalls,
|
|
@@ -178895,7 +179266,9 @@ var ts;
|
|
|
178895
179266
|
Session.prototype.executeCommand = function (request) {
|
|
178896
179267
|
var handler = this.handlers.get(request.command);
|
|
178897
179268
|
if (handler) {
|
|
178898
|
-
|
|
179269
|
+
var response = this.executeWithRequestId(request.seq, function () { return handler(request); });
|
|
179270
|
+
this.projectService.enableRequestedPlugins();
|
|
179271
|
+
return response;
|
|
178899
179272
|
}
|
|
178900
179273
|
else {
|
|
178901
179274
|
this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err);
|