typescript 4.8.0-dev.20220614 → 4.8.0-dev.20220617
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dynamicImportCompat.js +25 -0
- package/lib/tsc.js +115 -23
- package/lib/tsserver.js +617 -78
- package/lib/tsserverlibrary.d.ts +18 -2
- package/lib/tsserverlibrary.js +556 -77
- package/lib/typescript.d.ts +8 -0
- package/lib/typescript.js +279 -41
- package/lib/typescriptServices.d.ts +8 -0
- package/lib/typescriptServices.js +279 -41
- package/lib/typingsInstaller.js +133 -24
- package/package.json +20 -20
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.20220617";
|
|
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}'."),
|
|
@@ -9853,6 +9866,8 @@ var ts;
|
|
|
9853
9866
|
Qualified_name_0_is_not_allowed_without_a_leading_param_object_1: diag(8032, ts.DiagnosticCategory.Error, "Qualified_name_0_is_not_allowed_without_a_leading_param_object_1_8032", "Qualified name '{0}' is not allowed without a leading '@param {object} {1}'."),
|
|
9854
9867
|
A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags: diag(8033, ts.DiagnosticCategory.Error, "A_JSDoc_typedef_comment_may_not_contain_multiple_type_tags_8033", "A JSDoc '@typedef' comment may not contain multiple '@type' tags."),
|
|
9855
9868
|
The_tag_was_first_specified_here: diag(8034, ts.DiagnosticCategory.Error, "The_tag_was_first_specified_here_8034", "The tag was first specified here."),
|
|
9869
|
+
You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder: diag(8035, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder_8035", "You cannot rename elements that are defined in a 'node_modules' folder."),
|
|
9870
|
+
You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder: diag(8036, ts.DiagnosticCategory.Error, "You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder_8036", "You cannot rename elements that are defined in another 'node_modules' folder."),
|
|
9856
9871
|
Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9005, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_An_explicit_type_annotation_may_unblock_9005", "Declaration emit for this file requires using private name '{0}'. An explicit type annotation may unblock declaration emit."),
|
|
9857
9872
|
Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotation_may_unblock_declaration_emit: diag(9006, ts.DiagnosticCategory.Error, "Declaration_emit_for_this_file_requires_using_private_name_0_from_module_1_An_explicit_type_annotati_9006", "Declaration emit for this file requires using private name '{0}' from module '{1}'. An explicit type annotation may unblock declaration emit."),
|
|
9858
9873
|
JSX_attributes_must_only_be_assigned_a_non_empty_expression: diag(17000, ts.DiagnosticCategory.Error, "JSX_attributes_must_only_be_assigned_a_non_empty_expression_17000", "JSX attributes must only be assigned a non-empty 'expression'."),
|
|
@@ -35970,10 +35985,11 @@ var ts;
|
|
|
35970
35985
|
}
|
|
35971
35986
|
nextToken();
|
|
35972
35987
|
var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
|
|
35973
|
-
if (
|
|
35988
|
+
if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
|
|
35974
35989
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35975
35990
|
return undefined;
|
|
35976
35991
|
}
|
|
35992
|
+
nextToken();
|
|
35977
35993
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35978
35994
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35979
35995
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -49090,9 +49106,9 @@ var ts;
|
|
|
49090
49106
|
return moduleSpecifier && resolveExternalModuleName(moduleSpecifier, moduleSpecifier, /*ignoreErrors*/ true);
|
|
49091
49107
|
},
|
|
49092
49108
|
resolveExternalModuleSymbol: resolveExternalModuleSymbol,
|
|
49093
|
-
tryGetThisTypeAt: function (nodeIn, includeGlobalThis) {
|
|
49109
|
+
tryGetThisTypeAt: function (nodeIn, includeGlobalThis, container) {
|
|
49094
49110
|
var node = ts.getParseTreeNode(nodeIn);
|
|
49095
|
-
return node && tryGetThisTypeAt(node, includeGlobalThis);
|
|
49111
|
+
return node && tryGetThisTypeAt(node, includeGlobalThis, container);
|
|
49096
49112
|
},
|
|
49097
49113
|
getTypeArgumentConstraint: function (nodeIn) {
|
|
49098
49114
|
var node = ts.getParseTreeNode(nodeIn, ts.isTypeNode);
|
|
@@ -49387,6 +49403,7 @@ var ts;
|
|
|
49387
49403
|
var potentialNewTargetCollisions = [];
|
|
49388
49404
|
var potentialWeakMapSetCollisions = [];
|
|
49389
49405
|
var potentialReflectCollisions = [];
|
|
49406
|
+
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
49390
49407
|
var awaitedTypeStack = [];
|
|
49391
49408
|
var diagnostics = ts.createDiagnosticCollection();
|
|
49392
49409
|
var suggestionDiagnostics = ts.createDiagnosticCollection();
|
|
@@ -52722,6 +52739,9 @@ var ts;
|
|
|
52722
52739
|
if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
|
|
52723
52740
|
return { accessibility: 0 /* Accessible */ };
|
|
52724
52741
|
}
|
|
52742
|
+
if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
|
|
52743
|
+
return { accessibility: 0 /* Accessible */ };
|
|
52744
|
+
}
|
|
52725
52745
|
// Verify if the symbol is accessible
|
|
52726
52746
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
52727
52747
|
accessibility: 1 /* NotAccessible */,
|
|
@@ -53894,15 +53914,22 @@ var ts;
|
|
|
53894
53914
|
context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
|
|
53895
53915
|
return parameterNode;
|
|
53896
53916
|
function cloneBindingName(node) {
|
|
53897
|
-
return
|
|
53898
|
-
function
|
|
53917
|
+
return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
|
|
53918
|
+
function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
|
|
53899
53919
|
if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
|
|
53900
53920
|
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
53901
53921
|
}
|
|
53902
|
-
var visited = ts.visitEachChild(node,
|
|
53922
|
+
var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
|
|
53903
53923
|
if (ts.isBindingElement(visited)) {
|
|
53904
|
-
visited
|
|
53905
|
-
|
|
53924
|
+
if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
|
|
53925
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
|
|
53926
|
+
/* propertyName*/ undefined, visited.propertyName,
|
|
53927
|
+
/*initializer*/ undefined);
|
|
53928
|
+
}
|
|
53929
|
+
else {
|
|
53930
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
|
|
53931
|
+
/*initializer*/ undefined);
|
|
53932
|
+
}
|
|
53906
53933
|
}
|
|
53907
53934
|
if (!ts.nodeIsSynthesized(visited)) {
|
|
53908
53935
|
visited = ts.factory.cloneNode(visited);
|
|
@@ -59529,7 +59556,7 @@ var ts;
|
|
|
59529
59556
|
}
|
|
59530
59557
|
if (t.flags & 268435456 /* StringMapping */) {
|
|
59531
59558
|
var constraint = getBaseConstraint(t.type);
|
|
59532
|
-
return constraint ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59559
|
+
return constraint && constraint !== t.type ? getStringMappingType(t.symbol, constraint) : stringType;
|
|
59533
59560
|
}
|
|
59534
59561
|
if (t.flags & 8388608 /* IndexedAccess */) {
|
|
59535
59562
|
if (isMappedTypeGenericIndexedAccess(t)) {
|
|
@@ -62499,9 +62526,12 @@ var ts;
|
|
|
62499
62526
|
}
|
|
62500
62527
|
function getStringMappingType(symbol, type) {
|
|
62501
62528
|
return type.flags & (1048576 /* Union */ | 131072 /* Never */) ? mapType(type, function (t) { return getStringMappingType(symbol, t); }) :
|
|
62502
|
-
|
|
62503
|
-
|
|
62504
|
-
|
|
62529
|
+
// Mapping<Mapping<T>> === Mapping<T>
|
|
62530
|
+
type.flags & 268435456 /* StringMapping */ && symbol === type.symbol ? type :
|
|
62531
|
+
isGenericIndexType(type) || isPatternLiteralPlaceholderType(type) ? getStringMappingTypeForGenericType(symbol, isPatternLiteralPlaceholderType(type) && !(type.flags & 268435456 /* StringMapping */) ? getTemplateLiteralType(["", ""], [type]) : type) :
|
|
62532
|
+
type.flags & 128 /* StringLiteral */ ? getStringLiteralType(applyStringMapping(symbol, type.value)) :
|
|
62533
|
+
type.flags & 134217728 /* TemplateLiteral */ ? getTemplateLiteralType.apply(void 0, applyTemplateStringMapping(symbol, type.texts, type.types)) :
|
|
62534
|
+
type;
|
|
62505
62535
|
}
|
|
62506
62536
|
function applyStringMapping(symbol, str) {
|
|
62507
62537
|
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
@@ -62512,6 +62542,15 @@ var ts;
|
|
|
62512
62542
|
}
|
|
62513
62543
|
return str;
|
|
62514
62544
|
}
|
|
62545
|
+
function applyTemplateStringMapping(symbol, texts, types) {
|
|
62546
|
+
switch (intrinsicTypeKinds.get(symbol.escapedName)) {
|
|
62547
|
+
case 0 /* Uppercase */: return [texts.map(function (t) { return t.toUpperCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62548
|
+
case 1 /* Lowercase */: return [texts.map(function (t) { return t.toLowerCase(); }), types.map(function (t) { return getStringMappingType(symbol, t); })];
|
|
62549
|
+
case 2 /* Capitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toUpperCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
|
|
62550
|
+
case 3 /* Uncapitalize */: return [texts[0] === "" ? texts : __spreadArray([texts[0].charAt(0).toLowerCase() + texts[0].slice(1)], texts.slice(1), true), texts[0] === "" ? __spreadArray([getStringMappingType(symbol, types[0])], types.slice(1), true) : types];
|
|
62551
|
+
}
|
|
62552
|
+
return [texts, types];
|
|
62553
|
+
}
|
|
62515
62554
|
function getStringMappingTypeForGenericType(symbol, type) {
|
|
62516
62555
|
var id = getSymbolId(symbol) + "," + getTypeId(type);
|
|
62517
62556
|
var result = stringMappingTypes.get(id);
|
|
@@ -62753,7 +62792,7 @@ var ts;
|
|
|
62753
62792
|
accessNode;
|
|
62754
62793
|
}
|
|
62755
62794
|
function isPatternLiteralPlaceholderType(type) {
|
|
62756
|
-
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */));
|
|
62795
|
+
return !!(type.flags & (1 /* Any */ | 4 /* String */ | 8 /* Number */ | 64 /* BigInt */)) || !!(type.flags & 268435456 /* StringMapping */ && isPatternLiteralPlaceholderType(type.type));
|
|
62757
62796
|
}
|
|
62758
62797
|
function isPatternLiteralType(type) {
|
|
62759
62798
|
return !!(type.flags & 134217728 /* TemplateLiteral */) && ts.every(type.types, isPatternLiteralPlaceholderType);
|
|
@@ -65675,8 +65714,13 @@ var ts;
|
|
|
65675
65714
|
return;
|
|
65676
65715
|
}
|
|
65677
65716
|
reportRelationError(headMessage, source, target);
|
|
65678
|
-
if (
|
|
65679
|
-
|
|
65717
|
+
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)) {
|
|
65718
|
+
var syntheticParam = cloneTypeParameter(source);
|
|
65719
|
+
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
|
|
65720
|
+
if (hasNonCircularBaseConstraint(syntheticParam)) {
|
|
65721
|
+
var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
|
|
65722
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
|
|
65723
|
+
}
|
|
65680
65724
|
}
|
|
65681
65725
|
}
|
|
65682
65726
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
@@ -66460,6 +66504,13 @@ var ts;
|
|
|
66460
66504
|
return -1 /* True */;
|
|
66461
66505
|
}
|
|
66462
66506
|
}
|
|
66507
|
+
else if (target.flags & 268435456 /* StringMapping */) {
|
|
66508
|
+
if (!(source.flags & 268435456 /* StringMapping */)) {
|
|
66509
|
+
if (isMemberOfStringMapping(source, target)) {
|
|
66510
|
+
return -1 /* True */;
|
|
66511
|
+
}
|
|
66512
|
+
}
|
|
66513
|
+
}
|
|
66463
66514
|
if (sourceFlags & 8650752 /* TypeVariable */) {
|
|
66464
66515
|
// IndexedAccess comparisons are handled above in the `targetFlags & TypeFlage.IndexedAccess` branch
|
|
66465
66516
|
if (!(sourceFlags & 8388608 /* IndexedAccess */ && targetFlags & 8388608 /* IndexedAccess */)) {
|
|
@@ -66503,7 +66554,10 @@ var ts;
|
|
|
66503
66554
|
}
|
|
66504
66555
|
}
|
|
66505
66556
|
else if (sourceFlags & 268435456 /* StringMapping */) {
|
|
66506
|
-
if (targetFlags & 268435456 /* StringMapping */
|
|
66557
|
+
if (targetFlags & 268435456 /* StringMapping */) {
|
|
66558
|
+
if (source.symbol !== target.symbol) {
|
|
66559
|
+
return 0 /* False */;
|
|
66560
|
+
}
|
|
66507
66561
|
if (result = isRelatedTo(source.type, target.type, 3 /* Both */, reportErrors)) {
|
|
66508
66562
|
resetErrorInfo(saveErrorInfo);
|
|
66509
66563
|
return result;
|
|
@@ -67428,7 +67482,7 @@ var ts;
|
|
|
67428
67482
|
return typeCouldHaveTopLevelSingletonTypes(constraint);
|
|
67429
67483
|
}
|
|
67430
67484
|
}
|
|
67431
|
-
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */);
|
|
67485
|
+
return isUnitType(type) || !!(type.flags & 134217728 /* TemplateLiteral */) || !!(type.flags & 268435456 /* StringMapping */);
|
|
67432
67486
|
}
|
|
67433
67487
|
function getExactOptionalUnassignableProperties(source, target) {
|
|
67434
67488
|
if (isTupleType(source) && isTupleType(target))
|
|
@@ -68226,12 +68280,13 @@ var ts;
|
|
|
68226
68280
|
* with no call or construct signatures.
|
|
68227
68281
|
*/
|
|
68228
68282
|
function isObjectTypeWithInferableIndex(type) {
|
|
68283
|
+
var objectFlags = ts.getObjectFlags(type);
|
|
68229
68284
|
return type.flags & 2097152 /* Intersection */
|
|
68230
68285
|
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
68231
68286
|
: !!(type.symbol
|
|
68232
68287
|
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
68233
68288
|
&& !(type.symbol.flags & 32 /* Class */)
|
|
68234
|
-
&& !typeHasCallOrConstructSignatures(type)) || !!(
|
|
68289
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
68235
68290
|
}
|
|
68236
68291
|
function createSymbolWithType(source, type) {
|
|
68237
68292
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -68898,6 +68953,31 @@ var ts;
|
|
|
68898
68953
|
return success && result === 9 /* BigIntLiteral */ && scanner.getTextPos() === (s.length + 1) && !(flags & 512 /* ContainsSeparator */)
|
|
68899
68954
|
&& (!roundTripOnly || s === ts.pseudoBigIntToString({ negative: negative, base10Value: ts.parsePseudoBigInt(scanner.getTokenValue()) }));
|
|
68900
68955
|
}
|
|
68956
|
+
function isMemberOfStringMapping(source, target) {
|
|
68957
|
+
if (target.flags & (4 /* String */ | 3 /* AnyOrUnknown */)) {
|
|
68958
|
+
return true;
|
|
68959
|
+
}
|
|
68960
|
+
if (target.flags & 134217728 /* TemplateLiteral */) {
|
|
68961
|
+
return isTypeAssignableTo(source, target);
|
|
68962
|
+
}
|
|
68963
|
+
if (target.flags & 268435456 /* StringMapping */) {
|
|
68964
|
+
// We need to see whether applying the same mappings of the target
|
|
68965
|
+
// onto the source would produce an identical type *and* that
|
|
68966
|
+
// it's compatible with the inner-most non-string-mapped type.
|
|
68967
|
+
//
|
|
68968
|
+
// The intuition here is that if same mappings don't affect the source at all,
|
|
68969
|
+
// and the source is compatible with the unmapped target, then they must
|
|
68970
|
+
// still reside in the same domain.
|
|
68971
|
+
var mappingStack = [];
|
|
68972
|
+
while (target.flags & 268435456 /* StringMapping */) {
|
|
68973
|
+
mappingStack.unshift(target.symbol);
|
|
68974
|
+
target = target.type;
|
|
68975
|
+
}
|
|
68976
|
+
var mappedSource = ts.reduceLeft(mappingStack, function (memo, value) { return getStringMappingType(value, memo); }, source);
|
|
68977
|
+
return mappedSource === source && isMemberOfStringMapping(source, target);
|
|
68978
|
+
}
|
|
68979
|
+
return false;
|
|
68980
|
+
}
|
|
68901
68981
|
function isValidTypeForTemplateLiteralPlaceholder(source, target) {
|
|
68902
68982
|
if (source === target || target.flags & (1 /* Any */ | 4 /* String */)) {
|
|
68903
68983
|
return true;
|
|
@@ -68906,7 +68986,8 @@ var ts;
|
|
|
68906
68986
|
var value = source.value;
|
|
68907
68987
|
return !!(target.flags & 8 /* Number */ && isValidNumberString(value, /*roundTripOnly*/ false) ||
|
|
68908
68988
|
target.flags & 64 /* BigInt */ && isValidBigIntString(value, /*roundTripOnly*/ false) ||
|
|
68909
|
-
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName
|
|
68989
|
+
target.flags & (512 /* BooleanLiteral */ | 98304 /* Nullable */) && value === target.intrinsicName ||
|
|
68990
|
+
target.flags & 268435456 /* StringMapping */ && isMemberOfStringMapping(getStringLiteralType(value), target));
|
|
68910
68991
|
}
|
|
68911
68992
|
if (source.flags & 134217728 /* TemplateLiteral */) {
|
|
68912
68993
|
var texts = source.texts;
|
|
@@ -82830,6 +82911,22 @@ var ts;
|
|
|
82830
82911
|
}
|
|
82831
82912
|
});
|
|
82832
82913
|
}
|
|
82914
|
+
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
82915
|
+
var _a;
|
|
82916
|
+
for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
|
|
82917
|
+
var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
|
|
82918
|
+
if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
|
|
82919
|
+
var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
|
|
82920
|
+
ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
|
|
82921
|
+
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));
|
|
82922
|
+
if (!wrappingDeclaration.type) {
|
|
82923
|
+
// entire parameter does not have type annotation, suggest adding an annotation
|
|
82924
|
+
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)));
|
|
82925
|
+
}
|
|
82926
|
+
diagnostics.add(diagnostic);
|
|
82927
|
+
}
|
|
82928
|
+
}
|
|
82929
|
+
}
|
|
82833
82930
|
function bindingNameText(name) {
|
|
82834
82931
|
switch (name.kind) {
|
|
82835
82932
|
case 79 /* Identifier */:
|
|
@@ -83131,6 +83228,17 @@ var ts;
|
|
|
83131
83228
|
}
|
|
83132
83229
|
}
|
|
83133
83230
|
if (ts.isBindingElement(node)) {
|
|
83231
|
+
if (node.propertyName &&
|
|
83232
|
+
ts.isIdentifier(node.name) &&
|
|
83233
|
+
ts.isParameterDeclaration(node) &&
|
|
83234
|
+
ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
|
|
83235
|
+
// type F = ({a: string}) => void;
|
|
83236
|
+
// ^^^^^^
|
|
83237
|
+
// variable renaming in function type notation is confusing,
|
|
83238
|
+
// so we forbid it even if noUnusedLocals is not enabled
|
|
83239
|
+
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
83240
|
+
return;
|
|
83241
|
+
}
|
|
83134
83242
|
if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
|
|
83135
83243
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
83136
83244
|
}
|
|
@@ -86594,6 +86702,7 @@ var ts;
|
|
|
86594
86702
|
ts.clear(potentialNewTargetCollisions);
|
|
86595
86703
|
ts.clear(potentialWeakMapSetCollisions);
|
|
86596
86704
|
ts.clear(potentialReflectCollisions);
|
|
86705
|
+
ts.clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
86597
86706
|
ts.forEach(node.statements, checkSourceElement);
|
|
86598
86707
|
checkSourceElement(node.endOfFileToken);
|
|
86599
86708
|
checkDeferredNodes(node);
|
|
@@ -86609,6 +86718,9 @@ var ts;
|
|
|
86609
86718
|
}
|
|
86610
86719
|
});
|
|
86611
86720
|
}
|
|
86721
|
+
if (!node.isDeclarationFile) {
|
|
86722
|
+
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
86723
|
+
}
|
|
86612
86724
|
});
|
|
86613
86725
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
86614
86726
|
!node.isDeclarationFile &&
|
|
@@ -109350,7 +109462,7 @@ var ts;
|
|
|
109350
109462
|
});
|
|
109351
109463
|
return ret;
|
|
109352
109464
|
}
|
|
109353
|
-
function
|
|
109465
|
+
function filterBindingPatternInitializersAndRenamings(name) {
|
|
109354
109466
|
if (name.kind === 79 /* Identifier */) {
|
|
109355
109467
|
return name;
|
|
109356
109468
|
}
|
|
@@ -109366,7 +109478,12 @@ var ts;
|
|
|
109366
109478
|
if (elem.kind === 227 /* OmittedExpression */) {
|
|
109367
109479
|
return elem;
|
|
109368
109480
|
}
|
|
109369
|
-
|
|
109481
|
+
if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
|
|
109482
|
+
// Unnecessary property renaming is forbidden in types, so remove renaming
|
|
109483
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken,
|
|
109484
|
+
/* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109485
|
+
}
|
|
109486
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109370
109487
|
}
|
|
109371
109488
|
}
|
|
109372
109489
|
function ensureParameter(p, modifierMask, type) {
|
|
@@ -109375,7 +109492,7 @@ var ts;
|
|
|
109375
109492
|
oldDiag = getSymbolAccessibilityDiagnostic;
|
|
109376
109493
|
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
|
|
109377
109494
|
}
|
|
109378
|
-
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken,
|
|
109495
|
+
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
109496
|
ensureNoInitializer(p));
|
|
109380
109497
|
if (!suppressNewDiagnosticContexts) {
|
|
109381
109498
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
@@ -117518,6 +117635,7 @@ var ts;
|
|
|
117518
117635
|
ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
|
117519
117636
|
ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
|
|
117520
117637
|
ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
|
|
117638
|
+
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
117521
117639
|
]);
|
|
117522
117640
|
/**
|
|
117523
117641
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
@@ -135327,7 +135445,7 @@ var ts;
|
|
|
135327
135445
|
}
|
|
135328
135446
|
// Need to insert 'this.' before properties of `this` type, so only do that if `includeInsertTextCompletions`
|
|
135329
135447
|
if (preferences.includeCompletionsWithInsertText && scopeNode.kind !== 305 /* SourceFile */) {
|
|
135330
|
-
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false);
|
|
135448
|
+
var thisType = typeChecker.tryGetThisTypeAt(scopeNode, /*includeGlobalThis*/ false, ts.isClassLike(scopeNode.parent) ? scopeNode : undefined);
|
|
135331
135449
|
if (thisType && !isProbablyGlobalType(thisType, sourceFile, typeChecker)) {
|
|
135332
135450
|
for (var _i = 0, _a = getPropertiesForCompletion(thisType, typeChecker); _i < _a.length; _i++) {
|
|
135333
135451
|
var symbol = _a[_i];
|
|
@@ -144665,10 +144783,10 @@ var ts;
|
|
|
144665
144783
|
(function (ts) {
|
|
144666
144784
|
var Rename;
|
|
144667
144785
|
(function (Rename) {
|
|
144668
|
-
function getRenameInfo(program, sourceFile, position,
|
|
144786
|
+
function getRenameInfo(program, sourceFile, position, preferences) {
|
|
144669
144787
|
var node = ts.getAdjustedRenameLocation(ts.getTouchingPropertyName(sourceFile, position));
|
|
144670
144788
|
if (nodeIsEligibleForRename(node)) {
|
|
144671
|
-
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program,
|
|
144789
|
+
var renameInfo = getRenameInfoForNode(node, program.getTypeChecker(), sourceFile, program, preferences);
|
|
144672
144790
|
if (renameInfo) {
|
|
144673
144791
|
return renameInfo;
|
|
144674
144792
|
}
|
|
@@ -144676,7 +144794,7 @@ var ts;
|
|
|
144676
144794
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_this_element);
|
|
144677
144795
|
}
|
|
144678
144796
|
Rename.getRenameInfo = getRenameInfo;
|
|
144679
|
-
function getRenameInfoForNode(node, typeChecker, sourceFile, program,
|
|
144797
|
+
function getRenameInfoForNode(node, typeChecker, sourceFile, program, preferences) {
|
|
144680
144798
|
var symbol = typeChecker.getSymbolAtLocation(node);
|
|
144681
144799
|
if (!symbol) {
|
|
144682
144800
|
if (ts.isStringLiteralLike(node)) {
|
|
@@ -144704,7 +144822,12 @@ var ts;
|
|
|
144704
144822
|
return undefined;
|
|
144705
144823
|
}
|
|
144706
144824
|
if (ts.isStringLiteralLike(node) && ts.tryGetImportFromModuleSpecifier(node)) {
|
|
144707
|
-
return
|
|
144825
|
+
return preferences.allowRenameOfImportPath ? getRenameInfoForModule(node, sourceFile, symbol) : undefined;
|
|
144826
|
+
}
|
|
144827
|
+
// Disallow rename for elements that would rename across `*/node_modules/*` packages.
|
|
144828
|
+
var wouldRenameNodeModules = wouldRenameInOtherNodeModules(sourceFile, symbol, typeChecker, preferences);
|
|
144829
|
+
if (wouldRenameNodeModules) {
|
|
144830
|
+
return getRenameInfoError(wouldRenameNodeModules);
|
|
144708
144831
|
}
|
|
144709
144832
|
var kind = ts.SymbolDisplay.getSymbolKind(typeChecker, symbol, node);
|
|
144710
144833
|
var specifierName = (ts.isImportOrExportSpecifierName(node) || ts.isStringOrNumericLiteralLike(node) && node.parent.kind === 162 /* ComputedPropertyName */)
|
|
@@ -144718,6 +144841,49 @@ var ts;
|
|
|
144718
144841
|
var sourceFile = declaration.getSourceFile();
|
|
144719
144842
|
return program.isSourceFileDefaultLibrary(sourceFile) && ts.fileExtensionIs(sourceFile.fileName, ".d.ts" /* Dts */);
|
|
144720
144843
|
}
|
|
144844
|
+
function wouldRenameInOtherNodeModules(originalFile, symbol, checker, preferences) {
|
|
144845
|
+
if (!preferences.providePrefixAndSuffixTextForRename && symbol.flags & 2097152 /* Alias */) {
|
|
144846
|
+
var importSpecifier = symbol.declarations && ts.find(symbol.declarations, function (decl) { return ts.isImportSpecifier(decl); });
|
|
144847
|
+
if (importSpecifier && !importSpecifier.propertyName) {
|
|
144848
|
+
symbol = checker.getAliasedSymbol(symbol);
|
|
144849
|
+
}
|
|
144850
|
+
}
|
|
144851
|
+
var declarations = symbol.declarations;
|
|
144852
|
+
if (!declarations) {
|
|
144853
|
+
return undefined;
|
|
144854
|
+
}
|
|
144855
|
+
var originalPackage = getPackagePathComponents(originalFile.path);
|
|
144856
|
+
if (originalPackage === undefined) { // original source file is not in node_modules
|
|
144857
|
+
if (ts.some(declarations, function (declaration) { return ts.isInsideNodeModules(declaration.getSourceFile().path); })) {
|
|
144858
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_a_node_modules_folder;
|
|
144859
|
+
}
|
|
144860
|
+
else {
|
|
144861
|
+
return undefined;
|
|
144862
|
+
}
|
|
144863
|
+
}
|
|
144864
|
+
// original source file is in node_modules
|
|
144865
|
+
for (var _i = 0, declarations_4 = declarations; _i < declarations_4.length; _i++) {
|
|
144866
|
+
var declaration = declarations_4[_i];
|
|
144867
|
+
var declPackage = getPackagePathComponents(declaration.getSourceFile().path);
|
|
144868
|
+
if (declPackage) {
|
|
144869
|
+
var length_2 = Math.min(originalPackage.length, declPackage.length);
|
|
144870
|
+
for (var i = 0; i <= length_2; i++) {
|
|
144871
|
+
if (ts.compareStringsCaseSensitive(originalPackage[i], declPackage[i]) !== 0 /* EqualTo */) {
|
|
144872
|
+
return ts.Diagnostics.You_cannot_rename_elements_that_are_defined_in_another_node_modules_folder;
|
|
144873
|
+
}
|
|
144874
|
+
}
|
|
144875
|
+
}
|
|
144876
|
+
}
|
|
144877
|
+
return undefined;
|
|
144878
|
+
}
|
|
144879
|
+
function getPackagePathComponents(filePath) {
|
|
144880
|
+
var components = ts.getPathComponents(filePath);
|
|
144881
|
+
var nodeModulesIdx = components.lastIndexOf("node_modules");
|
|
144882
|
+
if (nodeModulesIdx === -1) {
|
|
144883
|
+
return undefined;
|
|
144884
|
+
}
|
|
144885
|
+
return components.slice(0, nodeModulesIdx + 2);
|
|
144886
|
+
}
|
|
144721
144887
|
function getRenameInfoForModule(node, sourceFile, moduleSymbol) {
|
|
144722
144888
|
if (!ts.isExternalModuleNameRelative(node.text)) {
|
|
144723
144889
|
return getRenameInfoError(ts.Diagnostics.You_cannot_rename_a_module_via_a_global_import);
|
|
@@ -145772,7 +145938,7 @@ var ts;
|
|
|
145772
145938
|
return type.symbol && (type.symbol.flags & 1536 /* Module */);
|
|
145773
145939
|
}
|
|
145774
145940
|
function visitVariableLikeDeclaration(decl) {
|
|
145775
|
-
if (!decl.initializer || ts.isBindingPattern(decl.name)) {
|
|
145941
|
+
if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
|
|
145776
145942
|
return;
|
|
145777
145943
|
}
|
|
145778
145944
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
|
|
@@ -145900,6 +146066,9 @@ var ts;
|
|
|
145900
146066
|
}
|
|
145901
146067
|
for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
|
|
145902
146068
|
var param = node.parameters[i];
|
|
146069
|
+
if (!isHintableDeclaration(param)) {
|
|
146070
|
+
continue;
|
|
146071
|
+
}
|
|
145903
146072
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
|
|
145904
146073
|
if (effectiveTypeAnnotation) {
|
|
145905
146074
|
continue;
|
|
@@ -145941,6 +146110,13 @@ var ts;
|
|
|
145941
146110
|
function isUndefined(name) {
|
|
145942
146111
|
return name === "undefined";
|
|
145943
146112
|
}
|
|
146113
|
+
function isHintableDeclaration(node) {
|
|
146114
|
+
if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
|
|
146115
|
+
var initializer = ts.skipParentheses(node.initializer);
|
|
146116
|
+
return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
|
|
146117
|
+
}
|
|
146118
|
+
return true;
|
|
146119
|
+
}
|
|
145944
146120
|
}
|
|
145945
146121
|
InlayHints.provideInlayHints = provideInlayHints;
|
|
145946
146122
|
})(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
|
|
@@ -155379,6 +155555,77 @@ var ts;
|
|
|
155379
155555
|
})(ts || (ts = {}));
|
|
155380
155556
|
/* @internal */
|
|
155381
155557
|
var ts;
|
|
155558
|
+
(function (ts) {
|
|
155559
|
+
var codefix;
|
|
155560
|
+
(function (codefix) {
|
|
155561
|
+
var fixId = "addMissingConstraint";
|
|
155562
|
+
var errorCodes = [
|
|
155563
|
+
// We want errors this could be attached to:
|
|
155564
|
+
// Diagnostics.This_type_parameter_probably_needs_an_extends_0_constraint
|
|
155565
|
+
ts.Diagnostics.Type_0_is_not_comparable_to_type_1.code,
|
|
155566
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1_Two_different_types_with_this_name_exist_but_they_are_unrelated.code,
|
|
155567
|
+
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,
|
|
155568
|
+
ts.Diagnostics.Type_0_is_not_assignable_to_type_1.code,
|
|
155569
|
+
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,
|
|
155570
|
+
ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
|
|
155571
|
+
ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
|
|
155572
|
+
ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
|
|
155573
|
+
];
|
|
155574
|
+
codefix.registerCodeFix({
|
|
155575
|
+
errorCodes: errorCodes,
|
|
155576
|
+
getCodeActions: function (context) {
|
|
155577
|
+
var sourceFile = context.sourceFile, span = context.span, program = context.program;
|
|
155578
|
+
var related = getDiagnosticRelatedInfo(program, sourceFile, span);
|
|
155579
|
+
if (!related) {
|
|
155580
|
+
return;
|
|
155581
|
+
}
|
|
155582
|
+
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
155583
|
+
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
155584
|
+
},
|
|
155585
|
+
fixIds: [fixId],
|
|
155586
|
+
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
155587
|
+
var info = getDiagnosticRelatedInfo(context.program, context.sourceFile, diag);
|
|
155588
|
+
if (!info)
|
|
155589
|
+
return;
|
|
155590
|
+
return addMissingConstraint(changes, info);
|
|
155591
|
+
}); },
|
|
155592
|
+
});
|
|
155593
|
+
function getDiagnosticRelatedInfo(program, sourceFile, span) {
|
|
155594
|
+
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
155595
|
+
if (!diag || !diag.relatedInformation)
|
|
155596
|
+
return;
|
|
155597
|
+
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
155598
|
+
if (!related)
|
|
155599
|
+
return;
|
|
155600
|
+
return related;
|
|
155601
|
+
}
|
|
155602
|
+
function addMissingConstraint(changes, related) {
|
|
155603
|
+
var decl = findAncestorMatchingSpan(related.file, related);
|
|
155604
|
+
if (!decl)
|
|
155605
|
+
return;
|
|
155606
|
+
if (ts.isIdentifier(decl) && ts.isTypeParameterDeclaration(decl.parent)) {
|
|
155607
|
+
decl = decl.parent;
|
|
155608
|
+
}
|
|
155609
|
+
if (!ts.isTypeParameterDeclaration(decl) || ts.isMappedTypeNode(decl.parent))
|
|
155610
|
+
return; // should only issue fix on type parameters written using `extends`
|
|
155611
|
+
var newConstraint = ts.flattenDiagnosticMessageText(related.messageText, "\n", 0).match(/`extends (.*)`/);
|
|
155612
|
+
if (!newConstraint)
|
|
155613
|
+
return;
|
|
155614
|
+
var newConstraintText = newConstraint[1];
|
|
155615
|
+
changes.insertText(related.file, related.start + related.length, " extends " + newConstraintText);
|
|
155616
|
+
}
|
|
155617
|
+
function findAncestorMatchingSpan(sourceFile, span) {
|
|
155618
|
+
var token = ts.getTokenAtPosition(sourceFile, span.start);
|
|
155619
|
+
var end = ts.textSpanEnd(span);
|
|
155620
|
+
while (token.end < end) {
|
|
155621
|
+
token = token.parent;
|
|
155622
|
+
}
|
|
155623
|
+
return token;
|
|
155624
|
+
}
|
|
155625
|
+
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
155626
|
+
})(ts || (ts = {}));
|
|
155627
|
+
/* @internal */
|
|
155628
|
+
var ts;
|
|
155382
155629
|
(function (ts) {
|
|
155383
155630
|
var codefix;
|
|
155384
155631
|
(function (codefix) {
|
|
@@ -161676,11 +161923,11 @@ var ts;
|
|
|
161676
161923
|
}
|
|
161677
161924
|
}
|
|
161678
161925
|
else if (ts.isVariableStatement(node) || ts.isVariableDeclarationList(node)) {
|
|
161679
|
-
var
|
|
161926
|
+
var declarations_6 = ts.isVariableStatement(node) ? node.declarationList.declarations : node.declarations;
|
|
161680
161927
|
var numInitializers = 0;
|
|
161681
161928
|
var lastInitializer = void 0;
|
|
161682
|
-
for (var _i = 0,
|
|
161683
|
-
var declaration =
|
|
161929
|
+
for (var _i = 0, declarations_5 = declarations_6; _i < declarations_5.length; _i++) {
|
|
161930
|
+
var declaration = declarations_5[_i];
|
|
161684
161931
|
if (declaration.initializer) {
|
|
161685
161932
|
numInitializers++;
|
|
161686
161933
|
lastInitializer = declaration.initializer;
|
|
@@ -165817,8 +166064,8 @@ var ts;
|
|
|
165817
166064
|
tags = __spreadArray(__spreadArray([], inheritedTags, true), tags, true);
|
|
165818
166065
|
}
|
|
165819
166066
|
};
|
|
165820
|
-
for (var _i = 0,
|
|
165821
|
-
var declaration =
|
|
166067
|
+
for (var _i = 0, declarations_7 = declarations; _i < declarations_7.length; _i++) {
|
|
166068
|
+
var declaration = declarations_7[_i];
|
|
165822
166069
|
_loop_21(declaration);
|
|
165823
166070
|
}
|
|
165824
166071
|
}
|
|
@@ -165844,8 +166091,8 @@ var ts;
|
|
|
165844
166091
|
if (inheritedDocs)
|
|
165845
166092
|
doc = doc.length === 0 ? inheritedDocs.slice() : inheritedDocs.concat(ts.lineBreakPart(), doc);
|
|
165846
166093
|
};
|
|
165847
|
-
for (var _i = 0,
|
|
165848
|
-
var declaration =
|
|
166094
|
+
for (var _i = 0, declarations_8 = declarations; _i < declarations_8.length; _i++) {
|
|
166095
|
+
var declaration = declarations_8[_i];
|
|
165849
166096
|
_loop_22(declaration);
|
|
165850
166097
|
}
|
|
165851
166098
|
}
|
|
@@ -167422,9 +167669,9 @@ var ts;
|
|
|
167422
167669
|
return ts.stringContains(path, "/node_modules/");
|
|
167423
167670
|
}
|
|
167424
167671
|
}
|
|
167425
|
-
function getRenameInfo(fileName, position,
|
|
167672
|
+
function getRenameInfo(fileName, position, preferences) {
|
|
167426
167673
|
synchronizeHostData();
|
|
167427
|
-
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position,
|
|
167674
|
+
return ts.Rename.getRenameInfo(program, getValidSourceFile(fileName), position, preferences || {});
|
|
167428
167675
|
}
|
|
167429
167676
|
function getRefactorContext(file, positionOrRange, preferences, formatOptions, triggerReason, kind) {
|
|
167430
167677
|
var _a = typeof positionOrRange === "number" ? [positionOrRange, undefined] : [positionOrRange.pos, positionOrRange.end], startPosition = _a[0], endPosition = _a[1];
|
|
@@ -168790,9 +169037,9 @@ var ts;
|
|
|
168790
169037
|
var _this = this;
|
|
168791
169038
|
return this.forwardJSONCall("getImplementationAtPosition('" + fileName + "', " + position + ")", function () { return _this.languageService.getImplementationAtPosition(fileName, position); });
|
|
168792
169039
|
};
|
|
168793
|
-
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position,
|
|
169040
|
+
LanguageServiceShimObject.prototype.getRenameInfo = function (fileName, position, preferences) {
|
|
168794
169041
|
var _this = this;
|
|
168795
|
-
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position,
|
|
169042
|
+
return this.forwardJSONCall("getRenameInfo('" + fileName + "', " + position + ")", function () { return _this.languageService.getRenameInfo(fileName, position, preferences); });
|
|
168796
169043
|
};
|
|
168797
169044
|
LanguageServiceShimObject.prototype.getSmartSelectionRange = function (fileName, position) {
|
|
168798
169045
|
var _this = this;
|
|
@@ -170590,6 +170837,38 @@ var ts;
|
|
|
170590
170837
|
}
|
|
170591
170838
|
return result.module;
|
|
170592
170839
|
};
|
|
170840
|
+
/*@internal*/
|
|
170841
|
+
Project.importServicePluginAsync = function (moduleName, initialDir, host, log, logErrors) {
|
|
170842
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170843
|
+
var resolvedPath, result, e_1, err;
|
|
170844
|
+
return __generator(this, function (_a) {
|
|
170845
|
+
switch (_a.label) {
|
|
170846
|
+
case 0:
|
|
170847
|
+
ts.Debug.assertIsDefined(host.importServicePlugin);
|
|
170848
|
+
resolvedPath = ts.combinePaths(initialDir, "node_modules");
|
|
170849
|
+
log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
|
|
170850
|
+
_a.label = 1;
|
|
170851
|
+
case 1:
|
|
170852
|
+
_a.trys.push([1, 3, , 4]);
|
|
170853
|
+
return [4 /*yield*/, host.importServicePlugin(resolvedPath, moduleName)];
|
|
170854
|
+
case 2:
|
|
170855
|
+
result = _a.sent();
|
|
170856
|
+
return [3 /*break*/, 4];
|
|
170857
|
+
case 3:
|
|
170858
|
+
e_1 = _a.sent();
|
|
170859
|
+
result = { module: undefined, error: e_1 };
|
|
170860
|
+
return [3 /*break*/, 4];
|
|
170861
|
+
case 4:
|
|
170862
|
+
if (result.error) {
|
|
170863
|
+
err = result.error.stack || result.error.message || JSON.stringify(result.error);
|
|
170864
|
+
(logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err);
|
|
170865
|
+
return [2 /*return*/, undefined];
|
|
170866
|
+
}
|
|
170867
|
+
return [2 /*return*/, result.module];
|
|
170868
|
+
}
|
|
170869
|
+
});
|
|
170870
|
+
});
|
|
170871
|
+
};
|
|
170593
170872
|
Project.prototype.isKnownTypesPackageName = function (name) {
|
|
170594
170873
|
return this.typingsCache.isKnownTypesPackageName(name);
|
|
170595
170874
|
};
|
|
@@ -171650,7 +171929,7 @@ var ts;
|
|
|
171650
171929
|
};
|
|
171651
171930
|
Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
|
|
171652
171931
|
var host = this.projectService.host;
|
|
171653
|
-
if (!host.require) {
|
|
171932
|
+
if (!host.require && !host.importServicePlugin) {
|
|
171654
171933
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
171655
171934
|
return;
|
|
171656
171935
|
}
|
|
@@ -171679,21 +171958,66 @@ var ts;
|
|
|
171679
171958
|
}
|
|
171680
171959
|
}
|
|
171681
171960
|
};
|
|
171682
|
-
|
|
171961
|
+
/**
|
|
171962
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'.
|
|
171963
|
+
*/
|
|
171964
|
+
/*@internal*/
|
|
171965
|
+
Project.prototype.beginEnablePluginSync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171683
171966
|
var _this = this;
|
|
171684
|
-
this.projectService.
|
|
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); };
|
|
171967
|
+
ts.Debug.assertIsDefined(this.projectService.host.require);
|
|
171690
171968
|
var errorLogs;
|
|
171969
|
+
var log = function (message) { return _this.projectService.logger.info(message); };
|
|
171691
171970
|
var logError = function (message) {
|
|
171692
|
-
(errorLogs
|
|
171971
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171693
171972
|
};
|
|
171694
171973
|
var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
|
|
171695
171974
|
return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
|
|
171696
171975
|
});
|
|
171976
|
+
return { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs };
|
|
171977
|
+
};
|
|
171978
|
+
/**
|
|
171979
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`.
|
|
171980
|
+
*/
|
|
171981
|
+
/*@internal*/
|
|
171982
|
+
Project.prototype.beginEnablePluginAsync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171983
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171984
|
+
var errorLogs, log, logError, resolvedModule, _i, searchPaths_1, searchPath;
|
|
171985
|
+
var _this = this;
|
|
171986
|
+
return __generator(this, function (_a) {
|
|
171987
|
+
switch (_a.label) {
|
|
171988
|
+
case 0:
|
|
171989
|
+
ts.Debug.assertIsDefined(this.projectService.host.importServicePlugin);
|
|
171990
|
+
log = function (message) { return _this.projectService.logger.info(message); };
|
|
171991
|
+
logError = function (message) {
|
|
171992
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171993
|
+
};
|
|
171994
|
+
_i = 0, searchPaths_1 = searchPaths;
|
|
171995
|
+
_a.label = 1;
|
|
171996
|
+
case 1:
|
|
171997
|
+
if (!(_i < searchPaths_1.length)) return [3 /*break*/, 4];
|
|
171998
|
+
searchPath = searchPaths_1[_i];
|
|
171999
|
+
return [4 /*yield*/, Project.importServicePluginAsync(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError)];
|
|
172000
|
+
case 2:
|
|
172001
|
+
resolvedModule = (_a.sent());
|
|
172002
|
+
if (resolvedModule !== undefined) {
|
|
172003
|
+
return [3 /*break*/, 4];
|
|
172004
|
+
}
|
|
172005
|
+
_a.label = 3;
|
|
172006
|
+
case 3:
|
|
172007
|
+
_i++;
|
|
172008
|
+
return [3 /*break*/, 1];
|
|
172009
|
+
case 4: return [2 /*return*/, { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs }];
|
|
172010
|
+
}
|
|
172011
|
+
});
|
|
172012
|
+
});
|
|
172013
|
+
};
|
|
172014
|
+
/**
|
|
172015
|
+
* Performs the remaining steps of enabling a plugin after its module has been instantiated.
|
|
172016
|
+
*/
|
|
172017
|
+
/*@internal*/
|
|
172018
|
+
Project.prototype.endEnablePlugin = function (_a) {
|
|
172019
|
+
var _this = this;
|
|
172020
|
+
var pluginConfigEntry = _a.pluginConfigEntry, pluginConfigOverrides = _a.pluginConfigOverrides, resolvedModule = _a.resolvedModule, errorLogs = _a.errorLogs;
|
|
171697
172021
|
if (resolvedModule) {
|
|
171698
172022
|
var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
|
|
171699
172023
|
if (configurationOverride) {
|
|
@@ -171705,10 +172029,13 @@ var ts;
|
|
|
171705
172029
|
this.enableProxy(resolvedModule, pluginConfigEntry);
|
|
171706
172030
|
}
|
|
171707
172031
|
else {
|
|
171708
|
-
ts.forEach(errorLogs,
|
|
172032
|
+
ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); });
|
|
171709
172033
|
this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
|
|
171710
172034
|
}
|
|
171711
172035
|
};
|
|
172036
|
+
Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
172037
|
+
this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
172038
|
+
};
|
|
171712
172039
|
Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) {
|
|
171713
172040
|
try {
|
|
171714
172041
|
if (typeof pluginModuleFactory !== "function") {
|
|
@@ -172360,7 +172687,7 @@ var ts;
|
|
|
172360
172687
|
/*@internal*/
|
|
172361
172688
|
ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
|
|
172362
172689
|
var host = this.projectService.host;
|
|
172363
|
-
if (!host.require) {
|
|
172690
|
+
if (!host.require && !host.importServicePlugin) {
|
|
172364
172691
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
172365
172692
|
return;
|
|
172366
172693
|
}
|
|
@@ -172379,7 +172706,7 @@ var ts;
|
|
|
172379
172706
|
this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
172380
172707
|
}
|
|
172381
172708
|
}
|
|
172382
|
-
this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172709
|
+
return this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172383
172710
|
};
|
|
172384
172711
|
/**
|
|
172385
172712
|
* Get the errors that dont have any file name associated
|
|
@@ -175801,6 +176128,147 @@ var ts;
|
|
|
175801
176128
|
}
|
|
175802
176129
|
return false;
|
|
175803
176130
|
};
|
|
176131
|
+
/*@internal*/
|
|
176132
|
+
ProjectService.prototype.requestEnablePlugin = function (project, pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
176133
|
+
var _a;
|
|
176134
|
+
if (!this.host.importServicePlugin && !this.host.require) {
|
|
176135
|
+
this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
176136
|
+
return;
|
|
176137
|
+
}
|
|
176138
|
+
this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
|
|
176139
|
+
if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
|
|
176140
|
+
this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
|
|
176141
|
+
return;
|
|
176142
|
+
}
|
|
176143
|
+
// If the host supports dynamic import, begin enabling the plugin asynchronously.
|
|
176144
|
+
if (this.host.importServicePlugin) {
|
|
176145
|
+
var importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
176146
|
+
(_a = this.pendingPluginEnablements) !== null && _a !== void 0 ? _a : (this.pendingPluginEnablements = new ts.Map());
|
|
176147
|
+
var promises = this.pendingPluginEnablements.get(project);
|
|
176148
|
+
if (!promises)
|
|
176149
|
+
this.pendingPluginEnablements.set(project, promises = []);
|
|
176150
|
+
promises.push(importPromise);
|
|
176151
|
+
return;
|
|
176152
|
+
}
|
|
176153
|
+
// Otherwise, load the plugin using `require`
|
|
176154
|
+
project.endEnablePlugin(project.beginEnablePluginSync(pluginConfigEntry, searchPaths, pluginConfigOverrides));
|
|
176155
|
+
};
|
|
176156
|
+
/* @internal */
|
|
176157
|
+
ProjectService.prototype.hasNewPluginEnablementRequests = function () {
|
|
176158
|
+
return !!this.pendingPluginEnablements;
|
|
176159
|
+
};
|
|
176160
|
+
/* @internal */
|
|
176161
|
+
ProjectService.prototype.hasPendingPluginEnablements = function () {
|
|
176162
|
+
return !!this.currentPluginEnablementPromise;
|
|
176163
|
+
};
|
|
176164
|
+
/**
|
|
176165
|
+
* Waits for any ongoing plugin enablement requests to complete.
|
|
176166
|
+
*/
|
|
176167
|
+
/* @internal */
|
|
176168
|
+
ProjectService.prototype.waitForPendingPlugins = function () {
|
|
176169
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176170
|
+
return __generator(this, function (_a) {
|
|
176171
|
+
switch (_a.label) {
|
|
176172
|
+
case 0:
|
|
176173
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
176174
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
176175
|
+
case 1:
|
|
176176
|
+
_a.sent();
|
|
176177
|
+
return [3 /*break*/, 0];
|
|
176178
|
+
case 2: return [2 /*return*/];
|
|
176179
|
+
}
|
|
176180
|
+
});
|
|
176181
|
+
});
|
|
176182
|
+
};
|
|
176183
|
+
/**
|
|
176184
|
+
* Starts enabling any requested plugins without waiting for the result.
|
|
176185
|
+
*/
|
|
176186
|
+
/* @internal */
|
|
176187
|
+
ProjectService.prototype.enableRequestedPlugins = function () {
|
|
176188
|
+
if (this.pendingPluginEnablements) {
|
|
176189
|
+
void this.enableRequestedPluginsAsync();
|
|
176190
|
+
}
|
|
176191
|
+
};
|
|
176192
|
+
ProjectService.prototype.enableRequestedPluginsAsync = function () {
|
|
176193
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176194
|
+
var entries;
|
|
176195
|
+
return __generator(this, function (_a) {
|
|
176196
|
+
switch (_a.label) {
|
|
176197
|
+
case 0:
|
|
176198
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
176199
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
176200
|
+
return [4 /*yield*/, this.waitForPendingPlugins()];
|
|
176201
|
+
case 1:
|
|
176202
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
176203
|
+
_a.sent();
|
|
176204
|
+
_a.label = 2;
|
|
176205
|
+
case 2:
|
|
176206
|
+
// Skip if there are no new plugin enablement requests
|
|
176207
|
+
if (!this.pendingPluginEnablements) {
|
|
176208
|
+
return [2 /*return*/];
|
|
176209
|
+
}
|
|
176210
|
+
entries = ts.arrayFrom(this.pendingPluginEnablements.entries());
|
|
176211
|
+
this.pendingPluginEnablements = undefined;
|
|
176212
|
+
// Start processing the requests, keeping track of the promise for the operation so that
|
|
176213
|
+
// project consumers can potentially wait for the plugins to load.
|
|
176214
|
+
this.currentPluginEnablementPromise = this.enableRequestedPluginsWorker(entries);
|
|
176215
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
176216
|
+
case 3:
|
|
176217
|
+
_a.sent();
|
|
176218
|
+
return [2 /*return*/];
|
|
176219
|
+
}
|
|
176220
|
+
});
|
|
176221
|
+
});
|
|
176222
|
+
};
|
|
176223
|
+
ProjectService.prototype.enableRequestedPluginsWorker = function (pendingPlugins) {
|
|
176224
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176225
|
+
var _this = this;
|
|
176226
|
+
return __generator(this, function (_a) {
|
|
176227
|
+
switch (_a.label) {
|
|
176228
|
+
case 0:
|
|
176229
|
+
// This should only be called from `enableRequestedPluginsAsync`, which ensures this precondition is met.
|
|
176230
|
+
ts.Debug.assert(this.currentPluginEnablementPromise === undefined);
|
|
176231
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
176232
|
+
// on a project with many plugins.
|
|
176233
|
+
return [4 /*yield*/, Promise.all(ts.map(pendingPlugins, function (_a) {
|
|
176234
|
+
var project = _a[0], promises = _a[1];
|
|
176235
|
+
return _this.enableRequestedPluginsForProjectAsync(project, promises);
|
|
176236
|
+
}))];
|
|
176237
|
+
case 1:
|
|
176238
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
176239
|
+
// on a project with many plugins.
|
|
176240
|
+
_a.sent();
|
|
176241
|
+
// Clear the pending operation and notify the client that projects have been updated.
|
|
176242
|
+
this.currentPluginEnablementPromise = undefined;
|
|
176243
|
+
this.sendProjectsUpdatedInBackgroundEvent();
|
|
176244
|
+
return [2 /*return*/];
|
|
176245
|
+
}
|
|
176246
|
+
});
|
|
176247
|
+
});
|
|
176248
|
+
};
|
|
176249
|
+
ProjectService.prototype.enableRequestedPluginsForProjectAsync = function (project, promises) {
|
|
176250
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176251
|
+
var results, _i, results_1, result;
|
|
176252
|
+
return __generator(this, function (_a) {
|
|
176253
|
+
switch (_a.label) {
|
|
176254
|
+
case 0: return [4 /*yield*/, Promise.all(promises)];
|
|
176255
|
+
case 1:
|
|
176256
|
+
results = _a.sent();
|
|
176257
|
+
if (project.isClosed()) {
|
|
176258
|
+
// project is not alive, so don't enable plugins.
|
|
176259
|
+
return [2 /*return*/];
|
|
176260
|
+
}
|
|
176261
|
+
for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
|
|
176262
|
+
result = results_1[_i];
|
|
176263
|
+
project.endEnablePlugin(result);
|
|
176264
|
+
}
|
|
176265
|
+
// Plugins may have modified external files, so mark the project as dirty.
|
|
176266
|
+
this.delayUpdateProjectGraph(project);
|
|
176267
|
+
return [2 /*return*/];
|
|
176268
|
+
}
|
|
176269
|
+
});
|
|
176270
|
+
});
|
|
176271
|
+
};
|
|
175804
176272
|
ProjectService.prototype.configurePlugin = function (args) {
|
|
175805
176273
|
// For any projects that already have the plugin loaded, configure the plugin
|
|
175806
176274
|
this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); });
|
|
@@ -176322,7 +176790,7 @@ var ts;
|
|
|
176322
176790
|
return info && !info.isLocal ? { fileName: info.fileName, pos: info.textSpan.start } : undefined;
|
|
176323
176791
|
}
|
|
176324
176792
|
function getReferencesWorker(projects, defaultProject, initialLocation, logger) {
|
|
176325
|
-
var _a;
|
|
176793
|
+
var _a, _b;
|
|
176326
176794
|
var perProjectResults = getPerProjectReferences(projects, defaultProject, initialLocation,
|
|
176327
176795
|
/*isForRename*/ false, function (project, position) {
|
|
176328
176796
|
logger.info("Finding references to " + position.fileName + " position " + position.pos + " in project " + project.getProjectName());
|
|
@@ -176342,7 +176810,7 @@ var ts;
|
|
|
176342
176810
|
// have started the other project searches from related symbols. Propagate the
|
|
176343
176811
|
// correct results to all other projects.
|
|
176344
176812
|
var defaultProjectResults = perProjectResults.get(defaultProject);
|
|
176345
|
-
if (((_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0].references[0]) === null ||
|
|
176813
|
+
if (((_b = (_a = defaultProjectResults === null || defaultProjectResults === void 0 ? void 0 : defaultProjectResults[0]) === null || _a === void 0 ? void 0 : _a.references[0]) === null || _b === void 0 ? void 0 : _b.isDefinition) === undefined) {
|
|
176346
176814
|
// Clear all isDefinition properties
|
|
176347
176815
|
perProjectResults.forEach(function (projectResults) {
|
|
176348
176816
|
for (var _i = 0, projectResults_2 = projectResults; _i < projectResults_2.length; _i++) {
|
|
@@ -176359,8 +176827,8 @@ var ts;
|
|
|
176359
176827
|
var knownSymbolSpans_1 = createDocumentSpanSet();
|
|
176360
176828
|
for (var _i = 0, defaultProjectResults_1 = defaultProjectResults; _i < defaultProjectResults_1.length; _i++) {
|
|
176361
176829
|
var referencedSymbol = defaultProjectResults_1[_i];
|
|
176362
|
-
for (var
|
|
176363
|
-
var ref = _c
|
|
176830
|
+
for (var _c = 0, _d = referencedSymbol.references; _c < _d.length; _c++) {
|
|
176831
|
+
var ref = _d[_c];
|
|
176364
176832
|
if (ref.isDefinition) {
|
|
176365
176833
|
knownSymbolSpans_1.add(ref);
|
|
176366
176834
|
// One is enough - updateIsDefinitionOfReferencedSymbols will fill out the set based on symbols
|
|
@@ -176479,23 +176947,30 @@ var ts;
|
|
|
176479
176947
|
var getSourceDefinition = ts.memoize(function () { return defaultProject.isSourceOfProjectReferenceRedirect(defaultDefinition.fileName) ?
|
|
176480
176948
|
defaultDefinition :
|
|
176481
176949
|
defaultProject.getLanguageService().getSourceMapper().tryGetSourcePosition(defaultDefinition); });
|
|
176482
|
-
//
|
|
176483
|
-
//
|
|
176484
|
-
|
|
176485
|
-
var searchedProjects = new ts.Set();
|
|
176950
|
+
// The keys of resultsMap allow us to check which projects have already been searched, but we also
|
|
176951
|
+
// maintain a set of strings because that's what `loadAncestorProjectTree` wants.
|
|
176952
|
+
var searchedProjectKeys = new ts.Set();
|
|
176486
176953
|
onCancellation: while (queue.length) {
|
|
176487
176954
|
while (queue.length) {
|
|
176488
176955
|
if (cancellationToken.isCancellationRequested())
|
|
176489
176956
|
break onCancellation;
|
|
176957
|
+
var skipCount = 0;
|
|
176958
|
+
for (; skipCount < queue.length && resultsMap.has(queue[skipCount].project); skipCount++)
|
|
176959
|
+
;
|
|
176960
|
+
if (skipCount === queue.length) {
|
|
176961
|
+
queue.length = 0;
|
|
176962
|
+
break;
|
|
176963
|
+
}
|
|
176964
|
+
if (skipCount > 0) {
|
|
176965
|
+
queue.splice(0, skipCount);
|
|
176966
|
+
}
|
|
176967
|
+
// NB: we may still skip if it's a project reference redirect
|
|
176490
176968
|
var _a = queue.shift(), project = _a.project, location = _a.location;
|
|
176491
176969
|
if (isLocationProjectReferenceRedirect(project, location))
|
|
176492
176970
|
continue;
|
|
176493
|
-
if (!ts.tryAddToSet(searchedProjects, getProjectKey(project)))
|
|
176494
|
-
continue;
|
|
176495
176971
|
var projectResults = searchPosition(project, location);
|
|
176496
|
-
|
|
176497
|
-
|
|
176498
|
-
}
|
|
176972
|
+
resultsMap.set(project, projectResults !== null && projectResults !== void 0 ? projectResults : server.emptyArray);
|
|
176973
|
+
searchedProjectKeys.add(getProjectKey(project));
|
|
176499
176974
|
}
|
|
176500
176975
|
// At this point, we know about all projects passed in as arguments and any projects in which
|
|
176501
176976
|
// `getResultsForPosition` has returned results. We expand that set to include any projects
|
|
@@ -176503,11 +176978,11 @@ var ts;
|
|
|
176503
176978
|
// containing `initialLocation`.
|
|
176504
176979
|
if (defaultDefinition) {
|
|
176505
176980
|
// This seems to mean "load all projects downstream from any member of `seenProjects`".
|
|
176506
|
-
projectService.loadAncestorProjectTree(
|
|
176981
|
+
projectService.loadAncestorProjectTree(searchedProjectKeys);
|
|
176507
176982
|
projectService.forEachEnabledProject(function (project) {
|
|
176508
176983
|
if (cancellationToken.isCancellationRequested())
|
|
176509
176984
|
return; // There's no mechanism for skipping the remaining projects
|
|
176510
|
-
if (
|
|
176985
|
+
if (resultsMap.has(project))
|
|
176511
176986
|
return; // Can loop forever without this (enqueue here, dequeue above, repeat)
|
|
176512
176987
|
var location = mapDefinitionInProject(defaultDefinition, project, getGeneratedDefinition, getSourceDefinition);
|
|
176513
176988
|
if (location) {
|
|
@@ -176518,9 +176993,10 @@ var ts;
|
|
|
176518
176993
|
}
|
|
176519
176994
|
// In the common case where there's only one project, return a simpler result to make
|
|
176520
176995
|
// it easier for the caller to skip post-processing.
|
|
176521
|
-
if (
|
|
176996
|
+
if (resultsMap.size === 1) {
|
|
176522
176997
|
var it = resultsMap.values().next();
|
|
176523
|
-
|
|
176998
|
+
ts.Debug.assert(!it.done);
|
|
176999
|
+
return it.value;
|
|
176524
177000
|
}
|
|
176525
177001
|
return resultsMap;
|
|
176526
177002
|
function searchPosition(project, location) {
|
|
@@ -176537,7 +177013,7 @@ var ts;
|
|
|
176537
177013
|
var originalScriptInfo = projectService.getScriptInfo(originalLocation.fileName);
|
|
176538
177014
|
for (var _i = 0, _a = originalScriptInfo.containingProjects; _i < _a.length; _i++) {
|
|
176539
177015
|
var project_1 = _a[_i];
|
|
176540
|
-
if (!project_1.isOrphan()) {
|
|
177016
|
+
if (!project_1.isOrphan() && !resultsMap.has(project_1)) { // Optimization: don't enqueue if will be discarded
|
|
176541
177017
|
queue.push({ project: project_1, location: originalLocation });
|
|
176542
177018
|
}
|
|
176543
177019
|
}
|
|
@@ -176546,7 +177022,7 @@ var ts;
|
|
|
176546
177022
|
symlinkedProjectsMap.forEach(function (symlinkedProjects, symlinkedPath) {
|
|
176547
177023
|
for (var _i = 0, symlinkedProjects_2 = symlinkedProjects; _i < symlinkedProjects_2.length; _i++) {
|
|
176548
177024
|
var symlinkedProject = symlinkedProjects_2[_i];
|
|
176549
|
-
if (!symlinkedProject.isOrphan()) {
|
|
177025
|
+
if (!symlinkedProject.isOrphan() && !resultsMap.has(symlinkedProject)) { // Optimization: don't enqueue if will be discarded
|
|
176550
177026
|
queue.push({ project: symlinkedProject, location: { fileName: symlinkedPath, pos: originalLocation.pos } });
|
|
176551
177027
|
}
|
|
176552
177028
|
}
|
|
@@ -176629,7 +177105,6 @@ var ts;
|
|
|
176629
177105
|
server.CommandNames.OrganizeImportsFull,
|
|
176630
177106
|
server.CommandNames.GetEditsForFileRename,
|
|
176631
177107
|
server.CommandNames.GetEditsForFileRenameFull,
|
|
176632
|
-
server.CommandNames.ConfigurePlugin,
|
|
176633
177108
|
server.CommandNames.PrepareCallHierarchy,
|
|
176634
177109
|
server.CommandNames.ProvideCallHierarchyIncomingCalls,
|
|
176635
177110
|
server.CommandNames.ProvideCallHierarchyOutgoingCalls,
|
|
@@ -177840,7 +178315,8 @@ var ts;
|
|
|
177840
178315
|
Session.prototype.getRenameInfo = function (args) {
|
|
177841
178316
|
var _a = this.getFileAndProject(args), file = _a.file, project = _a.project;
|
|
177842
178317
|
var position = this.getPositionInFile(args, file);
|
|
177843
|
-
|
|
178318
|
+
var preferences = this.getPreferences(file);
|
|
178319
|
+
return project.getLanguageService().getRenameInfo(file, position, preferences);
|
|
177844
178320
|
};
|
|
177845
178321
|
Session.prototype.getProjects = function (args, getScriptInfoEnsuringProjectsUptoDate, ignoreNoProjectError) {
|
|
177846
178322
|
var _a;
|
|
@@ -177891,10 +178367,11 @@ var ts;
|
|
|
177891
178367
|
var position = this.getPositionInFile(args, file);
|
|
177892
178368
|
var projects = this.getProjects(args);
|
|
177893
178369
|
var defaultProject = this.getDefaultProject(args);
|
|
177894
|
-
var
|
|
178370
|
+
var preferences = this.getPreferences(file);
|
|
178371
|
+
var renameInfo = this.mapRenameInfo(defaultProject.getLanguageService().getRenameInfo(file, position, preferences), ts.Debug.checkDefined(this.projectService.getScriptInfo(file)));
|
|
177895
178372
|
if (!renameInfo.canRename)
|
|
177896
178373
|
return simplifiedResult ? { info: renameInfo, locs: [] } : [];
|
|
177897
|
-
var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments,
|
|
178374
|
+
var locations = getRenameLocationsWorker(projects, defaultProject, { fileName: args.file, pos: position }, !!args.findInStrings, !!args.findInComments, preferences);
|
|
177898
178375
|
if (!simplifiedResult)
|
|
177899
178376
|
return locations;
|
|
177900
178377
|
return { info: renameInfo, locs: this.toSpanGroups(locations) };
|
|
@@ -178897,7 +179374,9 @@ var ts;
|
|
|
178897
179374
|
Session.prototype.executeCommand = function (request) {
|
|
178898
179375
|
var handler = this.handlers.get(request.command);
|
|
178899
179376
|
if (handler) {
|
|
178900
|
-
|
|
179377
|
+
var response = this.executeWithRequestId(request.seq, function () { return handler(request); });
|
|
179378
|
+
this.projectService.enableRequestedPlugins();
|
|
179379
|
+
return response;
|
|
178901
179380
|
}
|
|
178902
179381
|
else {
|
|
178903
179382
|
this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err);
|