@typescript-deploys/pr-build 4.8.0-pr-49481-2 → 4.8.0-pr-49554-2
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/cs/diagnosticMessages.generated.json +4 -2
- package/lib/de/diagnosticMessages.generated.json +4 -2
- package/lib/dynamicImportCompat.js +25 -0
- package/lib/es/diagnosticMessages.generated.json +4 -2
- package/lib/fr/diagnosticMessages.generated.json +4 -2
- package/lib/it/diagnosticMessages.generated.json +4 -2
- package/lib/ja/diagnosticMessages.generated.json +4 -2
- package/lib/ko/diagnosticMessages.generated.json +4 -2
- package/lib/pl/diagnosticMessages.generated.json +4 -2
- package/lib/pt-br/diagnosticMessages.generated.json +4 -2
- package/lib/ru/diagnosticMessages.generated.json +4 -2
- package/lib/tr/diagnosticMessages.generated.json +4 -2
- package/lib/tsc.js +82 -25
- package/lib/tsserver.js +430 -53
- package/lib/tsserverlibrary.d.ts +11 -3
- package/lib/tsserverlibrary.js +369 -52
- package/lib/typescript.d.ts +1 -1
- package/lib/typescript.js +124 -38
- package/lib/typescriptServices.d.ts +1 -1
- package/lib/typescriptServices.js +124 -38
- package/lib/typingsInstaller.js +96 -27
- package/lib/zh-cn/diagnosticMessages.generated.json +4 -2
- package/lib/zh-tw/diagnosticMessages.generated.json +4 -2
- package/package.json +2 -1
package/lib/tsserver.js
CHANGED
|
@@ -92,6 +92,15 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
92
92
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
93
93
|
};
|
|
94
94
|
})();
|
|
95
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
96
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
97
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
98
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
99
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
100
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
101
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
102
|
+
});
|
|
103
|
+
};
|
|
95
104
|
var ts;
|
|
96
105
|
(function (ts) {
|
|
97
106
|
// WARNING: The script `configurePrerelease.ts` uses a regexp to parse out these values.
|
|
@@ -100,7 +109,7 @@ var ts;
|
|
|
100
109
|
// The following is baselined as a literal template type without intervention
|
|
101
110
|
/** The version of the TypeScript compiler release */
|
|
102
111
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
103
|
-
ts.version = ts.versionMajorMinor + ".0-insiders.
|
|
112
|
+
ts.version = ts.versionMajorMinor + ".0-insiders.20220615";
|
|
104
113
|
/* @internal */
|
|
105
114
|
var Comparison;
|
|
106
115
|
(function (Comparison) {
|
|
@@ -2657,7 +2666,7 @@ var ts;
|
|
|
2657
2666
|
return members.length > 0 && members[0][0] === 0 ? members[0][1] : "0";
|
|
2658
2667
|
}
|
|
2659
2668
|
if (isFlags) {
|
|
2660
|
-
var result =
|
|
2669
|
+
var result = [];
|
|
2661
2670
|
var remainingFlags = value;
|
|
2662
2671
|
for (var _i = 0, members_1 = members; _i < members_1.length; _i++) {
|
|
2663
2672
|
var _a = members_1[_i], enumValue = _a[0], enumName = _a[1];
|
|
@@ -2665,12 +2674,12 @@ var ts;
|
|
|
2665
2674
|
break;
|
|
2666
2675
|
}
|
|
2667
2676
|
if (enumValue !== 0 && enumValue & value) {
|
|
2668
|
-
result
|
|
2677
|
+
result.push(enumName);
|
|
2669
2678
|
remainingFlags &= ~enumValue;
|
|
2670
2679
|
}
|
|
2671
2680
|
}
|
|
2672
2681
|
if (remainingFlags === 0) {
|
|
2673
|
-
return result;
|
|
2682
|
+
return result.join("|");
|
|
2674
2683
|
}
|
|
2675
2684
|
}
|
|
2676
2685
|
else {
|
|
@@ -2684,7 +2693,15 @@ var ts;
|
|
|
2684
2693
|
return value.toString();
|
|
2685
2694
|
}
|
|
2686
2695
|
Debug.formatEnum = formatEnum;
|
|
2696
|
+
var enumMemberCache = new ts.Map();
|
|
2687
2697
|
function getEnumMembers(enumObject) {
|
|
2698
|
+
// Assuming enum objects do not change at runtime, we can cache the enum members list
|
|
2699
|
+
// to reuse later. This saves us from reconstructing this each and every time we call
|
|
2700
|
+
// a formatting function (which can be expensive for large enums like SyntaxKind).
|
|
2701
|
+
var existing = enumMemberCache.get(enumObject);
|
|
2702
|
+
if (existing) {
|
|
2703
|
+
return existing;
|
|
2704
|
+
}
|
|
2688
2705
|
var result = [];
|
|
2689
2706
|
for (var name in enumObject) {
|
|
2690
2707
|
var value = enumObject[name];
|
|
@@ -2692,7 +2709,9 @@ var ts;
|
|
|
2692
2709
|
result.push([value, name]);
|
|
2693
2710
|
}
|
|
2694
2711
|
}
|
|
2695
|
-
|
|
2712
|
+
var sorted = ts.stableSort(result, function (x, y) { return ts.compareValues(x[0], y[0]); });
|
|
2713
|
+
enumMemberCache.set(enumObject, sorted);
|
|
2714
|
+
return sorted;
|
|
2696
2715
|
}
|
|
2697
2716
|
function formatSyntaxKind(kind) {
|
|
2698
2717
|
return formatEnum(kind, ts.SyntaxKind, /*isFlags*/ false);
|
|
@@ -4331,6 +4350,7 @@ var ts;
|
|
|
4331
4350
|
SyntaxKind[SyntaxKind["JSDocFunctionType"] = 317] = "JSDocFunctionType";
|
|
4332
4351
|
SyntaxKind[SyntaxKind["JSDocVariadicType"] = 318] = "JSDocVariadicType";
|
|
4333
4352
|
SyntaxKind[SyntaxKind["JSDocNamepathType"] = 319] = "JSDocNamepathType";
|
|
4353
|
+
SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
|
|
4334
4354
|
/** @deprecated Use SyntaxKind.JSDoc */
|
|
4335
4355
|
SyntaxKind[SyntaxKind["JSDocComment"] = 320] = "JSDocComment";
|
|
4336
4356
|
SyntaxKind[SyntaxKind["JSDocText"] = 321] = "JSDocText";
|
|
@@ -4405,7 +4425,6 @@ var ts;
|
|
|
4405
4425
|
SyntaxKind[SyntaxKind["LastJSDocTagNode"] = 347] = "LastJSDocTagNode";
|
|
4406
4426
|
/* @internal */ SyntaxKind[SyntaxKind["FirstContextualKeyword"] = 126] = "FirstContextualKeyword";
|
|
4407
4427
|
/* @internal */ SyntaxKind[SyntaxKind["LastContextualKeyword"] = 160] = "LastContextualKeyword";
|
|
4408
|
-
SyntaxKind[SyntaxKind["JSDoc"] = 320] = "JSDoc";
|
|
4409
4428
|
})(SyntaxKind = ts.SyntaxKind || (ts.SyntaxKind = {}));
|
|
4410
4429
|
var NodeFlags;
|
|
4411
4430
|
(function (NodeFlags) {
|
|
@@ -8468,6 +8487,7 @@ var ts;
|
|
|
8468
8487
|
The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2209, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_export_map_entry_0_in_file_1_Supply_the_roo_2209", "The project root is ambiguous, but is required to resolve export map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8469
8488
|
The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_rootDir_compiler_option_to_disambiguate: diag(2210, ts.DiagnosticCategory.Error, "The_project_root_is_ambiguous_but_is_required_to_resolve_import_map_entry_0_in_file_1_Supply_the_roo_2210", "The project root is ambiguous, but is required to resolve import map entry '{0}' in file '{1}'. Supply the `rootDir` compiler option to disambiguate."),
|
|
8470
8489
|
Add_extends_constraint: diag(2211, ts.DiagnosticCategory.Message, "Add_extends_constraint_2211", "Add `extends` constraint."),
|
|
8490
|
+
Add_extends_constraint_to_all_type_parameters: diag(2212, ts.DiagnosticCategory.Message, "Add_extends_constraint_to_all_type_parameters_2212", "Add `extends` constraint to all type parameters"),
|
|
8471
8491
|
Duplicate_identifier_0: diag(2300, ts.DiagnosticCategory.Error, "Duplicate_identifier_0_2300", "Duplicate identifier '{0}'."),
|
|
8472
8492
|
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: diag(2301, ts.DiagnosticCategory.Error, "Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor_2301", "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor."),
|
|
8473
8493
|
Static_members_cannot_reference_class_type_parameters: diag(2302, ts.DiagnosticCategory.Error, "Static_members_cannot_reference_class_type_parameters_2302", "Static members cannot reference class type parameters."),
|
|
@@ -8953,6 +8973,8 @@ var ts;
|
|
|
8953
8973
|
This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
|
|
8954
8974
|
An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
|
|
8955
8975
|
The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
8976
|
+
_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
|
|
8977
|
+
We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
|
|
8956
8978
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
8957
8979
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
8958
8980
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -35767,10 +35789,11 @@ var ts;
|
|
|
35767
35789
|
}
|
|
35768
35790
|
nextToken();
|
|
35769
35791
|
var typeArguments = parseDelimitedList(20 /* TypeArguments */, parseType);
|
|
35770
|
-
if (
|
|
35792
|
+
if (reScanGreaterToken() !== 31 /* GreaterThanToken */) {
|
|
35771
35793
|
// If it doesn't have the closing `>` then it's definitely not an type argument list.
|
|
35772
35794
|
return undefined;
|
|
35773
35795
|
}
|
|
35796
|
+
nextToken();
|
|
35774
35797
|
// We successfully parsed a type argument list. The next token determines whether we want to
|
|
35775
35798
|
// treat it as such. If the type argument list is followed by `(` or a template literal, as in
|
|
35776
35799
|
// `f<number>(42)`, we favor the type argument interpretation even though JavaScript would view
|
|
@@ -45196,7 +45219,7 @@ var ts;
|
|
|
45196
45219
|
case 164 /* Parameter */:
|
|
45197
45220
|
// Parameters with names are handled at the top of this function. Parameters
|
|
45198
45221
|
// without names can only come from JSDocFunctionTypes.
|
|
45199
|
-
ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " +
|
|
45222
|
+
ts.Debug.assert(node.parent.kind === 317 /* JSDocFunctionType */, "Impossible parameter parent kind", function () { return "parent is: " + ts.Debug.formatSyntaxKind(node.parent.kind) + ", expected JSDocFunctionType"; });
|
|
45200
45223
|
var functionType = node.parent;
|
|
45201
45224
|
var index = functionType.parameters.indexOf(node);
|
|
45202
45225
|
return "arg" + index;
|
|
@@ -49184,6 +49207,7 @@ var ts;
|
|
|
49184
49207
|
var potentialNewTargetCollisions = [];
|
|
49185
49208
|
var potentialWeakMapSetCollisions = [];
|
|
49186
49209
|
var potentialReflectCollisions = [];
|
|
49210
|
+
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
49187
49211
|
var awaitedTypeStack = [];
|
|
49188
49212
|
var diagnostics = ts.createDiagnosticCollection();
|
|
49189
49213
|
var suggestionDiagnostics = ts.createDiagnosticCollection();
|
|
@@ -52519,6 +52543,9 @@ var ts;
|
|
|
52519
52543
|
if (symbol && symbol.flags & 262144 /* TypeParameter */ && meaning & 788968 /* Type */) {
|
|
52520
52544
|
return { accessibility: 0 /* Accessible */ };
|
|
52521
52545
|
}
|
|
52546
|
+
if (!symbol && ts.isThisIdentifier(firstIdentifier) && isSymbolAccessible(getSymbolOfNode(ts.getThisContainer(firstIdentifier, /*includeArrowFunctions*/ false)), firstIdentifier, meaning, /*computeAliases*/ false).accessibility === 0 /* Accessible */) {
|
|
52547
|
+
return { accessibility: 0 /* Accessible */ };
|
|
52548
|
+
}
|
|
52522
52549
|
// Verify if the symbol is accessible
|
|
52523
52550
|
return (symbol && hasVisibleDeclarations(symbol, /*shouldComputeAliasToMakeVisible*/ true)) || {
|
|
52524
52551
|
accessibility: 1 /* NotAccessible */,
|
|
@@ -53691,15 +53718,22 @@ var ts;
|
|
|
53691
53718
|
context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
|
|
53692
53719
|
return parameterNode;
|
|
53693
53720
|
function cloneBindingName(node) {
|
|
53694
|
-
return
|
|
53695
|
-
function
|
|
53721
|
+
return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
|
|
53722
|
+
function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
|
|
53696
53723
|
if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
|
|
53697
53724
|
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
53698
53725
|
}
|
|
53699
|
-
var visited = ts.visitEachChild(node,
|
|
53726
|
+
var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
|
|
53700
53727
|
if (ts.isBindingElement(visited)) {
|
|
53701
|
-
visited
|
|
53702
|
-
|
|
53728
|
+
if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
|
|
53729
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
|
|
53730
|
+
/* propertyName*/ undefined, visited.propertyName,
|
|
53731
|
+
/*initializer*/ undefined);
|
|
53732
|
+
}
|
|
53733
|
+
else {
|
|
53734
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
|
|
53735
|
+
/*initializer*/ undefined);
|
|
53736
|
+
}
|
|
53703
53737
|
}
|
|
53704
53738
|
if (!ts.nodeIsSynthesized(visited)) {
|
|
53705
53739
|
visited = ts.factory.cloneNode(visited);
|
|
@@ -64909,7 +64943,7 @@ var ts;
|
|
|
64909
64943
|
return true;
|
|
64910
64944
|
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
64911
64945
|
return true;
|
|
64912
|
-
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
|
|
64946
|
+
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */)))
|
|
64913
64947
|
return true;
|
|
64914
64948
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
64915
64949
|
if (s & 1 /* Any */)
|
|
@@ -65473,8 +65507,12 @@ var ts;
|
|
|
65473
65507
|
}
|
|
65474
65508
|
reportRelationError(headMessage, source, target);
|
|
65475
65509
|
if (source.flags & 262144 /* TypeParameter */ && ((_b = (_a = source.symbol) === null || _a === void 0 ? void 0 : _a.declarations) === null || _b === void 0 ? void 0 : _b[0]) && !getConstraintOfType(source)) {
|
|
65476
|
-
var
|
|
65477
|
-
|
|
65510
|
+
var syntheticParam = cloneTypeParameter(source);
|
|
65511
|
+
syntheticParam.constraint = instantiateType(target, makeUnaryTypeMapper(source, syntheticParam));
|
|
65512
|
+
if (hasNonCircularBaseConstraint(syntheticParam)) {
|
|
65513
|
+
var targetConstraintString = typeToString(target, source.symbol.declarations[0]);
|
|
65514
|
+
associateRelatedInfo(ts.createDiagnosticForNode(source.symbol.declarations[0], ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint, targetConstraintString));
|
|
65515
|
+
}
|
|
65478
65516
|
}
|
|
65479
65517
|
}
|
|
65480
65518
|
function traceUnionsOrIntersectionsTooLarge(source, target) {
|
|
@@ -65613,7 +65651,7 @@ var ts;
|
|
|
65613
65651
|
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
65614
65652
|
}
|
|
65615
65653
|
if (target.flags & 2097152 /* Intersection */) {
|
|
65616
|
-
return typeRelatedToEachType(
|
|
65654
|
+
return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */);
|
|
65617
65655
|
}
|
|
65618
65656
|
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
65619
65657
|
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
@@ -68024,12 +68062,13 @@ var ts;
|
|
|
68024
68062
|
* with no call or construct signatures.
|
|
68025
68063
|
*/
|
|
68026
68064
|
function isObjectTypeWithInferableIndex(type) {
|
|
68065
|
+
var objectFlags = ts.getObjectFlags(type);
|
|
68027
68066
|
return type.flags & 2097152 /* Intersection */
|
|
68028
68067
|
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
68029
68068
|
: !!(type.symbol
|
|
68030
68069
|
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
68031
68070
|
&& !(type.symbol.flags & 32 /* Class */)
|
|
68032
|
-
&& !typeHasCallOrConstructSignatures(type)) || !!(
|
|
68071
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
68033
68072
|
}
|
|
68034
68073
|
function createSymbolWithType(source, type) {
|
|
68035
68074
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -82628,6 +82667,22 @@ var ts;
|
|
|
82628
82667
|
}
|
|
82629
82668
|
});
|
|
82630
82669
|
}
|
|
82670
|
+
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
82671
|
+
var _a;
|
|
82672
|
+
for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
|
|
82673
|
+
var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
|
|
82674
|
+
if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
|
|
82675
|
+
var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
|
|
82676
|
+
ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
|
|
82677
|
+
var diagnostic = ts.createDiagnosticForNode(node.name, ts.Diagnostics._0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, ts.declarationNameToString(node.name), ts.declarationNameToString(node.propertyName));
|
|
82678
|
+
if (!wrappingDeclaration.type) {
|
|
82679
|
+
// entire parameter does not have type annotation, suggest adding an annotation
|
|
82680
|
+
ts.addRelatedInfo(diagnostic, ts.createFileDiagnostic(ts.getSourceFileOfNode(wrappingDeclaration), wrappingDeclaration.end, 1, ts.Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here, ts.declarationNameToString(node.propertyName)));
|
|
82681
|
+
}
|
|
82682
|
+
diagnostics.add(diagnostic);
|
|
82683
|
+
}
|
|
82684
|
+
}
|
|
82685
|
+
}
|
|
82631
82686
|
function bindingNameText(name) {
|
|
82632
82687
|
switch (name.kind) {
|
|
82633
82688
|
case 79 /* Identifier */:
|
|
@@ -82929,6 +82984,17 @@ var ts;
|
|
|
82929
82984
|
}
|
|
82930
82985
|
}
|
|
82931
82986
|
if (ts.isBindingElement(node)) {
|
|
82987
|
+
if (node.propertyName &&
|
|
82988
|
+
ts.isIdentifier(node.name) &&
|
|
82989
|
+
ts.isParameterDeclaration(node) &&
|
|
82990
|
+
ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
|
|
82991
|
+
// type F = ({a: string}) => void;
|
|
82992
|
+
// ^^^^^^
|
|
82993
|
+
// variable renaming in function type notation is confusing,
|
|
82994
|
+
// so we forbid it even if noUnusedLocals is not enabled
|
|
82995
|
+
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
82996
|
+
return;
|
|
82997
|
+
}
|
|
82932
82998
|
if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
|
|
82933
82999
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
82934
83000
|
}
|
|
@@ -86392,6 +86458,7 @@ var ts;
|
|
|
86392
86458
|
ts.clear(potentialNewTargetCollisions);
|
|
86393
86459
|
ts.clear(potentialWeakMapSetCollisions);
|
|
86394
86460
|
ts.clear(potentialReflectCollisions);
|
|
86461
|
+
ts.clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
86395
86462
|
ts.forEach(node.statements, checkSourceElement);
|
|
86396
86463
|
checkSourceElement(node.endOfFileToken);
|
|
86397
86464
|
checkDeferredNodes(node);
|
|
@@ -86407,6 +86474,9 @@ var ts;
|
|
|
86407
86474
|
}
|
|
86408
86475
|
});
|
|
86409
86476
|
}
|
|
86477
|
+
if (!node.isDeclarationFile) {
|
|
86478
|
+
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
86479
|
+
}
|
|
86410
86480
|
});
|
|
86411
86481
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
86412
86482
|
!node.isDeclarationFile &&
|
|
@@ -108457,7 +108527,7 @@ var ts;
|
|
|
108457
108527
|
return getTypeAliasDeclarationVisibilityError;
|
|
108458
108528
|
}
|
|
108459
108529
|
else {
|
|
108460
|
-
return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.
|
|
108530
|
+
return ts.Debug.assertNever(node, "Attempted to set a declaration diagnostic context for unhandled node kind: " + ts.Debug.formatSyntaxKind(node.kind));
|
|
108461
108531
|
}
|
|
108462
108532
|
function getVariableDeclarationTypeVisibilityDiagnosticMessage(symbolAccessibilityResult) {
|
|
108463
108533
|
if (node.kind === 254 /* VariableDeclaration */ || node.kind === 203 /* BindingElement */) {
|
|
@@ -108668,7 +108738,7 @@ var ts;
|
|
|
108668
108738
|
ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_name_1_from_private_module_2 :
|
|
108669
108739
|
ts.Diagnostics.Parameter_0_of_accessor_has_or_is_using_private_name_1;
|
|
108670
108740
|
default:
|
|
108671
|
-
return ts.Debug.fail("Unknown parent for parameter: " + ts.
|
|
108741
|
+
return ts.Debug.fail("Unknown parent for parameter: " + ts.Debug.formatSyntaxKind(node.parent.kind));
|
|
108672
108742
|
}
|
|
108673
108743
|
}
|
|
108674
108744
|
function getTypeParameterConstraintVisibilityError() {
|
|
@@ -109148,7 +109218,7 @@ var ts;
|
|
|
109148
109218
|
});
|
|
109149
109219
|
return ret;
|
|
109150
109220
|
}
|
|
109151
|
-
function
|
|
109221
|
+
function filterBindingPatternInitializersAndRenamings(name) {
|
|
109152
109222
|
if (name.kind === 79 /* Identifier */) {
|
|
109153
109223
|
return name;
|
|
109154
109224
|
}
|
|
@@ -109164,7 +109234,12 @@ var ts;
|
|
|
109164
109234
|
if (elem.kind === 227 /* OmittedExpression */) {
|
|
109165
109235
|
return elem;
|
|
109166
109236
|
}
|
|
109167
|
-
|
|
109237
|
+
if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
|
|
109238
|
+
// Unnecessary property renaming is forbidden in types, so remove renaming
|
|
109239
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken,
|
|
109240
|
+
/* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109241
|
+
}
|
|
109242
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109168
109243
|
}
|
|
109169
109244
|
}
|
|
109170
109245
|
function ensureParameter(p, modifierMask, type) {
|
|
@@ -109173,7 +109248,7 @@ var ts;
|
|
|
109173
109248
|
oldDiag = getSymbolAccessibilityDiagnostic;
|
|
109174
109249
|
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
|
|
109175
109250
|
}
|
|
109176
|
-
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken,
|
|
109251
|
+
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
|
|
109177
109252
|
ensureNoInitializer(p));
|
|
109178
109253
|
if (!suppressNewDiagnosticContexts) {
|
|
109179
109254
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
@@ -109434,7 +109509,7 @@ var ts;
|
|
|
109434
109509
|
while (ts.length(lateMarkedStatements)) {
|
|
109435
109510
|
var i = lateMarkedStatements.shift();
|
|
109436
109511
|
if (!ts.isLateVisibilityPaintedStatement(i)) {
|
|
109437
|
-
return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " +
|
|
109512
|
+
return ts.Debug.fail("Late replaced statement was found which is not handled by the declaration transformer!: " + ts.Debug.formatSyntaxKind(i.kind));
|
|
109438
109513
|
}
|
|
109439
109514
|
var priorNeedsDeclare = needsDeclare;
|
|
109440
109515
|
needsDeclare = i.parent && ts.isSourceFile(i.parent) && !(ts.isExternalModule(i.parent) && isBundledEmit);
|
|
@@ -109617,7 +109692,7 @@ var ts;
|
|
|
109617
109692
|
return cleanup(input);
|
|
109618
109693
|
return cleanup(factory.updateImportTypeNode(input, factory.updateLiteralTypeNode(input.argument, rewriteModuleSpecifier(input, input.argument.literal)), input.assertions, input.qualifier, ts.visitNodes(input.typeArguments, visitDeclarationSubtree, ts.isTypeNode), input.isTypeOf));
|
|
109619
109694
|
}
|
|
109620
|
-
default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.
|
|
109695
|
+
default: ts.Debug.assertNever(input, "Attempted to process unhandled node kind: " + ts.Debug.formatSyntaxKind(input.kind));
|
|
109621
109696
|
}
|
|
109622
109697
|
}
|
|
109623
109698
|
if (ts.isTupleTypeNode(input) && (ts.getLineAndCharacterOfPosition(currentSourceFile, input.pos).line === ts.getLineAndCharacterOfPosition(currentSourceFile, input.end).line)) {
|
|
@@ -109939,7 +110014,7 @@ var ts;
|
|
|
109939
110014
|
}
|
|
109940
110015
|
}
|
|
109941
110016
|
// Anything left unhandled is an error, so this should be unreachable
|
|
109942
|
-
return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.
|
|
110017
|
+
return ts.Debug.assertNever(input, "Unhandled top-level node in declaration emit: " + ts.Debug.formatSyntaxKind(input.kind));
|
|
109943
110018
|
function cleanup(node) {
|
|
109944
110019
|
if (isEnclosingDeclaration(input)) {
|
|
109945
110020
|
enclosingDeclaration = previousEnclosingDeclaration;
|
|
@@ -117316,6 +117391,7 @@ var ts;
|
|
|
117316
117391
|
ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
|
117317
117392
|
ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
|
|
117318
117393
|
ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
|
|
117394
|
+
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
117319
117395
|
]);
|
|
117320
117396
|
/**
|
|
117321
117397
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
@@ -122450,9 +122526,11 @@ var ts;
|
|
|
122450
122526
|
}
|
|
122451
122527
|
function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
|
|
122452
122528
|
ts.Debug.assert(!!resolution.refCount);
|
|
122529
|
+
var affectingLocations = resolution.affectingLocations;
|
|
122530
|
+
if (!affectingLocations.length)
|
|
122531
|
+
return;
|
|
122453
122532
|
if (addToResolutionsWithOnlyAffectingLocations)
|
|
122454
122533
|
resolutionsWithOnlyAffectingLocations.push(resolution);
|
|
122455
|
-
var affectingLocations = resolution.affectingLocations;
|
|
122456
122534
|
// Watch package json
|
|
122457
122535
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
122458
122536
|
var affectingLocation = affectingLocations_1[_i];
|
|
@@ -145149,7 +145227,7 @@ var ts;
|
|
|
145149
145227
|
return type.symbol && (type.symbol.flags & 1536 /* Module */);
|
|
145150
145228
|
}
|
|
145151
145229
|
function visitVariableLikeDeclaration(decl) {
|
|
145152
|
-
if (!decl.initializer || ts.isBindingPattern(decl.name)) {
|
|
145230
|
+
if (!decl.initializer || ts.isBindingPattern(decl.name) || ts.isVariableDeclaration(decl) && !isHintableDeclaration(decl)) {
|
|
145153
145231
|
return;
|
|
145154
145232
|
}
|
|
145155
145233
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(decl);
|
|
@@ -145277,6 +145355,9 @@ var ts;
|
|
|
145277
145355
|
}
|
|
145278
145356
|
for (var i = 0; i < node.parameters.length && i < signature.parameters.length; ++i) {
|
|
145279
145357
|
var param = node.parameters[i];
|
|
145358
|
+
if (!isHintableDeclaration(param)) {
|
|
145359
|
+
continue;
|
|
145360
|
+
}
|
|
145280
145361
|
var effectiveTypeAnnotation = ts.getEffectiveTypeAnnotationNode(param);
|
|
145281
145362
|
if (effectiveTypeAnnotation) {
|
|
145282
145363
|
continue;
|
|
@@ -145318,6 +145399,13 @@ var ts;
|
|
|
145318
145399
|
function isUndefined(name) {
|
|
145319
145400
|
return name === "undefined";
|
|
145320
145401
|
}
|
|
145402
|
+
function isHintableDeclaration(node) {
|
|
145403
|
+
if ((ts.isParameterDeclaration(node) || ts.isVariableDeclaration(node) && ts.isVarConst(node)) && node.initializer) {
|
|
145404
|
+
var initializer = ts.skipParentheses(node.initializer);
|
|
145405
|
+
return !(isHintableLiteral(initializer) || ts.isNewExpression(initializer) || ts.isObjectLiteralExpression(initializer) || ts.isAssertionExpression(initializer));
|
|
145406
|
+
}
|
|
145407
|
+
return true;
|
|
145408
|
+
}
|
|
145321
145409
|
}
|
|
145322
145410
|
InlayHints.provideInlayHints = provideInlayHints;
|
|
145323
145411
|
})(InlayHints = ts.InlayHints || (ts.InlayHints = {}));
|
|
@@ -150068,7 +150156,7 @@ var ts;
|
|
|
150068
150156
|
return {
|
|
150069
150157
|
indentation: indentation,
|
|
150070
150158
|
prefix: (insertLeadingComma ? "," : "") + this.newLineCharacter,
|
|
150071
|
-
suffix: insertTrailingComma ? "," : ""
|
|
150159
|
+
suffix: insertTrailingComma ? "," : ts.isInterfaceDeclaration(node) && isEmpty ? ";" : ""
|
|
150072
150160
|
};
|
|
150073
150161
|
};
|
|
150074
150162
|
ChangeTracker.prototype.insertNodeAfterComma = function (sourceFile, after, newNode) {
|
|
@@ -154770,6 +154858,7 @@ var ts;
|
|
|
154770
154858
|
ts.Diagnostics.Argument_of_type_0_is_not_assignable_to_parameter_of_type_1_with_exactOptionalPropertyTypes_Colon_true_Consider_adding_undefined_to_the_types_of_the_target_s_properties.code,
|
|
154771
154859
|
ts.Diagnostics.Property_0_is_incompatible_with_index_signature.code,
|
|
154772
154860
|
ts.Diagnostics.Property_0_in_type_1_is_not_assignable_to_type_2.code,
|
|
154861
|
+
ts.Diagnostics.Type_0_does_not_satisfy_the_constraint_1.code,
|
|
154773
154862
|
];
|
|
154774
154863
|
codefix.registerCodeFix({
|
|
154775
154864
|
errorCodes: errorCodes,
|
|
@@ -154780,7 +154869,7 @@ var ts;
|
|
|
154780
154869
|
return;
|
|
154781
154870
|
}
|
|
154782
154871
|
var changes = ts.textChanges.ChangeTracker.with(context, function (t) { return addMissingConstraint(t, related); });
|
|
154783
|
-
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.
|
|
154872
|
+
return [codefix.createCodeFixAction(fixId, changes, ts.Diagnostics.Add_extends_constraint, fixId, ts.Diagnostics.Add_extends_constraint_to_all_type_parameters)];
|
|
154784
154873
|
},
|
|
154785
154874
|
fixIds: [fixId],
|
|
154786
154875
|
getAllCodeActions: function (context) { return codefix.codeFixAll(context, errorCodes, function (changes, diag) {
|
|
@@ -154791,13 +154880,10 @@ var ts;
|
|
|
154791
154880
|
}); },
|
|
154792
154881
|
});
|
|
154793
154882
|
function getDiagnosticRelatedInfo(program, sourceFile, span) {
|
|
154794
|
-
var
|
|
154795
|
-
if (!
|
|
154883
|
+
var diag = ts.find(program.getSemanticDiagnostics(sourceFile), function (diag) { return diag.start === span.start && diag.length === span.length; });
|
|
154884
|
+
if (!diag || !diag.relatedInformation)
|
|
154796
154885
|
return;
|
|
154797
|
-
var
|
|
154798
|
-
if (!diag.relatedInformation)
|
|
154799
|
-
return;
|
|
154800
|
-
var related = ts.filter(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; })[0];
|
|
154886
|
+
var related = ts.find(diag.relatedInformation, function (related) { return related.code === ts.Diagnostics.This_type_parameter_might_need_an_extends_0_constraint.code; });
|
|
154801
154887
|
if (!related)
|
|
154802
154888
|
return;
|
|
154803
154889
|
return related;
|
|
@@ -155892,7 +155978,7 @@ var ts;
|
|
|
155892
155978
|
var checker = context.program.getTypeChecker();
|
|
155893
155979
|
var props = ts.map(info.properties, function (prop) {
|
|
155894
155980
|
var initializer = tryGetValueFromType(context, checker, importAdder, quotePreference, checker.getTypeOfSymbol(prop), info.parentDeclaration);
|
|
155895
|
-
return ts.factory.createPropertyAssignment(
|
|
155981
|
+
return ts.factory.createPropertyAssignment(createPropertyNameFromSymbol(prop, target, quotePreference, checker), initializer);
|
|
155896
155982
|
});
|
|
155897
155983
|
var options = {
|
|
155898
155984
|
leadingTriviaOption: ts.textChanges.LeadingTriviaOption.Exclude,
|
|
@@ -156012,6 +156098,15 @@ var ts;
|
|
|
156012
156098
|
var declaration = ts.findAncestor(callExpression, function (n) { return ts.isMethodDeclaration(n) || ts.isConstructorDeclaration(n); });
|
|
156013
156099
|
return declaration && declaration.parent === node ? declaration : undefined;
|
|
156014
156100
|
}
|
|
156101
|
+
function createPropertyNameFromSymbol(symbol, target, quotePreference, checker) {
|
|
156102
|
+
if (ts.isTransientSymbol(symbol) && symbol.nameType && symbol.nameType.flags & 8192 /* UniqueESSymbol */) {
|
|
156103
|
+
var expression = checker.symbolToExpression(symbol.nameType.symbol, 111551 /* Value */, symbol.valueDeclaration, 1048576 /* AllowUniqueESSymbolType */);
|
|
156104
|
+
if (expression) {
|
|
156105
|
+
return ts.factory.createComputedPropertyName(expression);
|
|
156106
|
+
}
|
|
156107
|
+
}
|
|
156108
|
+
return ts.createPropertyNameNodeForIdentifierOrLiteral(symbol.name, target, quotePreference === 0 /* Single */);
|
|
156109
|
+
}
|
|
156015
156110
|
})(codefix = ts.codefix || (ts.codefix = {}));
|
|
156016
156111
|
})(ts || (ts = {}));
|
|
156017
156112
|
/* @internal */
|
|
@@ -158739,7 +158834,7 @@ var ts;
|
|
|
158739
158834
|
/*questionToken*/ undefined, typeParameters, parameters, type, createStubbedMethodBody(quotePreference));
|
|
158740
158835
|
case 168 /* MethodSignature */:
|
|
158741
158836
|
return ts.factory.createMethodSignature(modifiers, name,
|
|
158742
|
-
/*questionToken*/ undefined, typeParameters, parameters, type);
|
|
158837
|
+
/*questionToken*/ undefined, typeParameters, parameters, type === undefined ? ts.factory.createKeywordTypeNode(155 /* UnknownKeyword */) : type);
|
|
158743
158838
|
case 256 /* FunctionDeclaration */:
|
|
158744
158839
|
return ts.factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, createStubbedBody(ts.Diagnostics.Function_not_implemented.message, quotePreference));
|
|
158745
158840
|
default:
|
|
@@ -170459,6 +170554,38 @@ var ts;
|
|
|
170459
170554
|
}
|
|
170460
170555
|
return result.module;
|
|
170461
170556
|
};
|
|
170557
|
+
/*@internal*/
|
|
170558
|
+
Project.importServicePluginAsync = function (moduleName, initialDir, host, log, logErrors) {
|
|
170559
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170560
|
+
var resolvedPath, result, e_1, err;
|
|
170561
|
+
return __generator(this, function (_a) {
|
|
170562
|
+
switch (_a.label) {
|
|
170563
|
+
case 0:
|
|
170564
|
+
ts.Debug.assertIsDefined(host.importServicePlugin);
|
|
170565
|
+
resolvedPath = ts.combinePaths(initialDir, "node_modules");
|
|
170566
|
+
log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
|
|
170567
|
+
_a.label = 1;
|
|
170568
|
+
case 1:
|
|
170569
|
+
_a.trys.push([1, 3, , 4]);
|
|
170570
|
+
return [4 /*yield*/, host.importServicePlugin(resolvedPath, moduleName)];
|
|
170571
|
+
case 2:
|
|
170572
|
+
result = _a.sent();
|
|
170573
|
+
return [3 /*break*/, 4];
|
|
170574
|
+
case 3:
|
|
170575
|
+
e_1 = _a.sent();
|
|
170576
|
+
result = { module: undefined, error: e_1 };
|
|
170577
|
+
return [3 /*break*/, 4];
|
|
170578
|
+
case 4:
|
|
170579
|
+
if (result.error) {
|
|
170580
|
+
err = result.error.stack || result.error.message || JSON.stringify(result.error);
|
|
170581
|
+
(logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err);
|
|
170582
|
+
return [2 /*return*/, undefined];
|
|
170583
|
+
}
|
|
170584
|
+
return [2 /*return*/, result.module];
|
|
170585
|
+
}
|
|
170586
|
+
});
|
|
170587
|
+
});
|
|
170588
|
+
};
|
|
170462
170589
|
Project.prototype.isKnownTypesPackageName = function (name) {
|
|
170463
170590
|
return this.typingsCache.isKnownTypesPackageName(name);
|
|
170464
170591
|
};
|
|
@@ -171519,7 +171646,7 @@ var ts;
|
|
|
171519
171646
|
};
|
|
171520
171647
|
Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
|
|
171521
171648
|
var host = this.projectService.host;
|
|
171522
|
-
if (!host.require) {
|
|
171649
|
+
if (!host.require && !host.importServicePlugin) {
|
|
171523
171650
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
171524
171651
|
return;
|
|
171525
171652
|
}
|
|
@@ -171548,21 +171675,66 @@ var ts;
|
|
|
171548
171675
|
}
|
|
171549
171676
|
}
|
|
171550
171677
|
};
|
|
171551
|
-
|
|
171678
|
+
/**
|
|
171679
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'.
|
|
171680
|
+
*/
|
|
171681
|
+
/*@internal*/
|
|
171682
|
+
Project.prototype.beginEnablePluginSync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171552
171683
|
var _this = this;
|
|
171553
|
-
this.projectService.
|
|
171554
|
-
if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
|
|
171555
|
-
this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
|
|
171556
|
-
return;
|
|
171557
|
-
}
|
|
171558
|
-
var log = function (message) { return _this.projectService.logger.info(message); };
|
|
171684
|
+
ts.Debug.assertIsDefined(this.projectService.host.require);
|
|
171559
171685
|
var errorLogs;
|
|
171686
|
+
var log = function (message) { return _this.projectService.logger.info(message); };
|
|
171560
171687
|
var logError = function (message) {
|
|
171561
|
-
(errorLogs
|
|
171688
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171562
171689
|
};
|
|
171563
171690
|
var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
|
|
171564
171691
|
return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
|
|
171565
171692
|
});
|
|
171693
|
+
return { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs };
|
|
171694
|
+
};
|
|
171695
|
+
/**
|
|
171696
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`.
|
|
171697
|
+
*/
|
|
171698
|
+
/*@internal*/
|
|
171699
|
+
Project.prototype.beginEnablePluginAsync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171700
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171701
|
+
var errorLogs, log, logError, resolvedModule, _i, searchPaths_1, searchPath;
|
|
171702
|
+
var _this = this;
|
|
171703
|
+
return __generator(this, function (_a) {
|
|
171704
|
+
switch (_a.label) {
|
|
171705
|
+
case 0:
|
|
171706
|
+
ts.Debug.assertIsDefined(this.projectService.host.importServicePlugin);
|
|
171707
|
+
log = function (message) { return _this.projectService.logger.info(message); };
|
|
171708
|
+
logError = function (message) {
|
|
171709
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171710
|
+
};
|
|
171711
|
+
_i = 0, searchPaths_1 = searchPaths;
|
|
171712
|
+
_a.label = 1;
|
|
171713
|
+
case 1:
|
|
171714
|
+
if (!(_i < searchPaths_1.length)) return [3 /*break*/, 4];
|
|
171715
|
+
searchPath = searchPaths_1[_i];
|
|
171716
|
+
return [4 /*yield*/, Project.importServicePluginAsync(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError)];
|
|
171717
|
+
case 2:
|
|
171718
|
+
resolvedModule = (_a.sent());
|
|
171719
|
+
if (resolvedModule !== undefined) {
|
|
171720
|
+
return [3 /*break*/, 4];
|
|
171721
|
+
}
|
|
171722
|
+
_a.label = 3;
|
|
171723
|
+
case 3:
|
|
171724
|
+
_i++;
|
|
171725
|
+
return [3 /*break*/, 1];
|
|
171726
|
+
case 4: return [2 /*return*/, { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs }];
|
|
171727
|
+
}
|
|
171728
|
+
});
|
|
171729
|
+
});
|
|
171730
|
+
};
|
|
171731
|
+
/**
|
|
171732
|
+
* Performs the remaining steps of enabling a plugin after its module has been instantiated.
|
|
171733
|
+
*/
|
|
171734
|
+
/*@internal*/
|
|
171735
|
+
Project.prototype.endEnablePlugin = function (_a) {
|
|
171736
|
+
var _this = this;
|
|
171737
|
+
var pluginConfigEntry = _a.pluginConfigEntry, pluginConfigOverrides = _a.pluginConfigOverrides, resolvedModule = _a.resolvedModule, errorLogs = _a.errorLogs;
|
|
171566
171738
|
if (resolvedModule) {
|
|
171567
171739
|
var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
|
|
171568
171740
|
if (configurationOverride) {
|
|
@@ -171574,10 +171746,13 @@ var ts;
|
|
|
171574
171746
|
this.enableProxy(resolvedModule, pluginConfigEntry);
|
|
171575
171747
|
}
|
|
171576
171748
|
else {
|
|
171577
|
-
ts.forEach(errorLogs,
|
|
171749
|
+
ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); });
|
|
171578
171750
|
this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
|
|
171579
171751
|
}
|
|
171580
171752
|
};
|
|
171753
|
+
Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171754
|
+
this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
171755
|
+
};
|
|
171581
171756
|
Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) {
|
|
171582
171757
|
try {
|
|
171583
171758
|
if (typeof pluginModuleFactory !== "function") {
|
|
@@ -172229,7 +172404,7 @@ var ts;
|
|
|
172229
172404
|
/*@internal*/
|
|
172230
172405
|
ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
|
|
172231
172406
|
var host = this.projectService.host;
|
|
172232
|
-
if (!host.require) {
|
|
172407
|
+
if (!host.require && !host.importServicePlugin) {
|
|
172233
172408
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
172234
172409
|
return;
|
|
172235
172410
|
}
|
|
@@ -172248,7 +172423,7 @@ var ts;
|
|
|
172248
172423
|
this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
172249
172424
|
}
|
|
172250
172425
|
}
|
|
172251
|
-
this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172426
|
+
return this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172252
172427
|
};
|
|
172253
172428
|
/**
|
|
172254
172429
|
* Get the errors that dont have any file name associated
|
|
@@ -175670,6 +175845,147 @@ var ts;
|
|
|
175670
175845
|
}
|
|
175671
175846
|
return false;
|
|
175672
175847
|
};
|
|
175848
|
+
/*@internal*/
|
|
175849
|
+
ProjectService.prototype.requestEnablePlugin = function (project, pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
175850
|
+
var _a;
|
|
175851
|
+
if (!this.host.importServicePlugin && !this.host.require) {
|
|
175852
|
+
this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
175853
|
+
return;
|
|
175854
|
+
}
|
|
175855
|
+
this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
|
|
175856
|
+
if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
|
|
175857
|
+
this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
|
|
175858
|
+
return;
|
|
175859
|
+
}
|
|
175860
|
+
// If the host supports dynamic import, begin enabling the plugin asynchronously.
|
|
175861
|
+
if (this.host.importServicePlugin) {
|
|
175862
|
+
var importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
175863
|
+
(_a = this.pendingPluginEnablements) !== null && _a !== void 0 ? _a : (this.pendingPluginEnablements = new ts.Map());
|
|
175864
|
+
var promises = this.pendingPluginEnablements.get(project);
|
|
175865
|
+
if (!promises)
|
|
175866
|
+
this.pendingPluginEnablements.set(project, promises = []);
|
|
175867
|
+
promises.push(importPromise);
|
|
175868
|
+
return;
|
|
175869
|
+
}
|
|
175870
|
+
// Otherwise, load the plugin using `require`
|
|
175871
|
+
project.endEnablePlugin(project.beginEnablePluginSync(pluginConfigEntry, searchPaths, pluginConfigOverrides));
|
|
175872
|
+
};
|
|
175873
|
+
/* @internal */
|
|
175874
|
+
ProjectService.prototype.hasNewPluginEnablementRequests = function () {
|
|
175875
|
+
return !!this.pendingPluginEnablements;
|
|
175876
|
+
};
|
|
175877
|
+
/* @internal */
|
|
175878
|
+
ProjectService.prototype.hasPendingPluginEnablements = function () {
|
|
175879
|
+
return !!this.currentPluginEnablementPromise;
|
|
175880
|
+
};
|
|
175881
|
+
/**
|
|
175882
|
+
* Waits for any ongoing plugin enablement requests to complete.
|
|
175883
|
+
*/
|
|
175884
|
+
/* @internal */
|
|
175885
|
+
ProjectService.prototype.waitForPendingPlugins = function () {
|
|
175886
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175887
|
+
return __generator(this, function (_a) {
|
|
175888
|
+
switch (_a.label) {
|
|
175889
|
+
case 0:
|
|
175890
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
175891
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
175892
|
+
case 1:
|
|
175893
|
+
_a.sent();
|
|
175894
|
+
return [3 /*break*/, 0];
|
|
175895
|
+
case 2: return [2 /*return*/];
|
|
175896
|
+
}
|
|
175897
|
+
});
|
|
175898
|
+
});
|
|
175899
|
+
};
|
|
175900
|
+
/**
|
|
175901
|
+
* Starts enabling any requested plugins without waiting for the result.
|
|
175902
|
+
*/
|
|
175903
|
+
/* @internal */
|
|
175904
|
+
ProjectService.prototype.enableRequestedPlugins = function () {
|
|
175905
|
+
if (this.pendingPluginEnablements) {
|
|
175906
|
+
void this.enableRequestedPluginsAsync();
|
|
175907
|
+
}
|
|
175908
|
+
};
|
|
175909
|
+
ProjectService.prototype.enableRequestedPluginsAsync = function () {
|
|
175910
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175911
|
+
var entries;
|
|
175912
|
+
return __generator(this, function (_a) {
|
|
175913
|
+
switch (_a.label) {
|
|
175914
|
+
case 0:
|
|
175915
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
175916
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
175917
|
+
return [4 /*yield*/, this.waitForPendingPlugins()];
|
|
175918
|
+
case 1:
|
|
175919
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
175920
|
+
_a.sent();
|
|
175921
|
+
_a.label = 2;
|
|
175922
|
+
case 2:
|
|
175923
|
+
// Skip if there are no new plugin enablement requests
|
|
175924
|
+
if (!this.pendingPluginEnablements) {
|
|
175925
|
+
return [2 /*return*/];
|
|
175926
|
+
}
|
|
175927
|
+
entries = ts.arrayFrom(this.pendingPluginEnablements.entries());
|
|
175928
|
+
this.pendingPluginEnablements = undefined;
|
|
175929
|
+
// Start processing the requests, keeping track of the promise for the operation so that
|
|
175930
|
+
// project consumers can potentially wait for the plugins to load.
|
|
175931
|
+
this.currentPluginEnablementPromise = this.enableRequestedPluginsWorker(entries);
|
|
175932
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
175933
|
+
case 3:
|
|
175934
|
+
_a.sent();
|
|
175935
|
+
return [2 /*return*/];
|
|
175936
|
+
}
|
|
175937
|
+
});
|
|
175938
|
+
});
|
|
175939
|
+
};
|
|
175940
|
+
ProjectService.prototype.enableRequestedPluginsWorker = function (pendingPlugins) {
|
|
175941
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175942
|
+
var _this = this;
|
|
175943
|
+
return __generator(this, function (_a) {
|
|
175944
|
+
switch (_a.label) {
|
|
175945
|
+
case 0:
|
|
175946
|
+
// This should only be called from `enableRequestedPluginsAsync`, which ensures this precondition is met.
|
|
175947
|
+
ts.Debug.assert(this.currentPluginEnablementPromise === undefined);
|
|
175948
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
175949
|
+
// on a project with many plugins.
|
|
175950
|
+
return [4 /*yield*/, Promise.all(ts.map(pendingPlugins, function (_a) {
|
|
175951
|
+
var project = _a[0], promises = _a[1];
|
|
175952
|
+
return _this.enableRequestedPluginsForProjectAsync(project, promises);
|
|
175953
|
+
}))];
|
|
175954
|
+
case 1:
|
|
175955
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
175956
|
+
// on a project with many plugins.
|
|
175957
|
+
_a.sent();
|
|
175958
|
+
// Clear the pending operation and notify the client that projects have been updated.
|
|
175959
|
+
this.currentPluginEnablementPromise = undefined;
|
|
175960
|
+
this.sendProjectsUpdatedInBackgroundEvent();
|
|
175961
|
+
return [2 /*return*/];
|
|
175962
|
+
}
|
|
175963
|
+
});
|
|
175964
|
+
});
|
|
175965
|
+
};
|
|
175966
|
+
ProjectService.prototype.enableRequestedPluginsForProjectAsync = function (project, promises) {
|
|
175967
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175968
|
+
var results, _i, results_1, result;
|
|
175969
|
+
return __generator(this, function (_a) {
|
|
175970
|
+
switch (_a.label) {
|
|
175971
|
+
case 0: return [4 /*yield*/, Promise.all(promises)];
|
|
175972
|
+
case 1:
|
|
175973
|
+
results = _a.sent();
|
|
175974
|
+
if (project.isClosed()) {
|
|
175975
|
+
// project is not alive, so don't enable plugins.
|
|
175976
|
+
return [2 /*return*/];
|
|
175977
|
+
}
|
|
175978
|
+
for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
|
|
175979
|
+
result = results_1[_i];
|
|
175980
|
+
project.endEnablePlugin(result);
|
|
175981
|
+
}
|
|
175982
|
+
// Plugins may have modified external files, so mark the project as dirty.
|
|
175983
|
+
this.delayUpdateProjectGraph(project);
|
|
175984
|
+
return [2 /*return*/];
|
|
175985
|
+
}
|
|
175986
|
+
});
|
|
175987
|
+
});
|
|
175988
|
+
};
|
|
175673
175989
|
ProjectService.prototype.configurePlugin = function (args) {
|
|
175674
175990
|
// For any projects that already have the plugin loaded, configure the plugin
|
|
175675
175991
|
this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); });
|
|
@@ -176498,7 +176814,6 @@ var ts;
|
|
|
176498
176814
|
server.CommandNames.OrganizeImportsFull,
|
|
176499
176815
|
server.CommandNames.GetEditsForFileRename,
|
|
176500
176816
|
server.CommandNames.GetEditsForFileRenameFull,
|
|
176501
|
-
server.CommandNames.ConfigurePlugin,
|
|
176502
176817
|
server.CommandNames.PrepareCallHierarchy,
|
|
176503
176818
|
server.CommandNames.ProvideCallHierarchyIncomingCalls,
|
|
176504
176819
|
server.CommandNames.ProvideCallHierarchyOutgoingCalls,
|
|
@@ -178766,7 +179081,9 @@ var ts;
|
|
|
178766
179081
|
Session.prototype.executeCommand = function (request) {
|
|
178767
179082
|
var handler = this.handlers.get(request.command);
|
|
178768
179083
|
if (handler) {
|
|
178769
|
-
|
|
179084
|
+
var response = this.executeWithRequestId(request.seq, function () { return handler(request); });
|
|
179085
|
+
this.projectService.enableRequestedPlugins();
|
|
179086
|
+
return response;
|
|
178770
179087
|
}
|
|
178771
179088
|
else {
|
|
178772
179089
|
this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err);
|
|
@@ -179680,6 +179997,8 @@ var ts;
|
|
|
179680
179997
|
})(server = ts.server || (ts.server = {}));
|
|
179681
179998
|
})(ts || (ts = {}));
|
|
179682
179999
|
/*@internal*/
|
|
180000
|
+
/// <reference lib="dom" />
|
|
180001
|
+
/// <reference lib="webworker.importscripts" />
|
|
179683
180002
|
var ts;
|
|
179684
180003
|
(function (ts) {
|
|
179685
180004
|
var server;
|
|
@@ -179785,11 +180104,31 @@ var ts;
|
|
|
179785
180104
|
return MainProcessLogger;
|
|
179786
180105
|
}(BaseLogger));
|
|
179787
180106
|
server.MainProcessLogger = MainProcessLogger;
|
|
180107
|
+
// Attempt to load `dynamicImport`
|
|
180108
|
+
if (typeof importScripts === "function") {
|
|
180109
|
+
try {
|
|
180110
|
+
// NOTE: importScripts is synchronous
|
|
180111
|
+
importScripts("dynamicImportCompat.js");
|
|
180112
|
+
}
|
|
180113
|
+
catch (_a) {
|
|
180114
|
+
// ignored
|
|
180115
|
+
}
|
|
180116
|
+
}
|
|
179788
180117
|
function createWebSystem(host, args, getExecutingFilePath) {
|
|
180118
|
+
var _this = this;
|
|
179789
180119
|
var returnEmptyString = function () { return ""; };
|
|
179790
180120
|
var getExecutingDirectoryPath = ts.memoize(function () { return ts.memoize(function () { return ts.ensureTrailingDirectorySeparator(ts.getDirectoryPath(getExecutingFilePath())); }); });
|
|
179791
180121
|
// Later we could map ^memfs:/ to do something special if we want to enable more functionality like module resolution or something like that
|
|
179792
180122
|
var getWebPath = function (path) { return ts.startsWith(path, ts.directorySeparator) ? path.replace(ts.directorySeparator, getExecutingDirectoryPath()) : undefined; };
|
|
180123
|
+
var dynamicImport = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
180124
|
+
return __generator(this, function (_a) {
|
|
180125
|
+
// Use syntactic dynamic import first, if available
|
|
180126
|
+
if (server.dynamicImport) {
|
|
180127
|
+
return [2 /*return*/, server.dynamicImport(id)];
|
|
180128
|
+
}
|
|
180129
|
+
throw new Error("Dynamic import not implemented");
|
|
180130
|
+
});
|
|
180131
|
+
}); };
|
|
179793
180132
|
return {
|
|
179794
180133
|
args: args,
|
|
179795
180134
|
newLine: "\r\n",
|
|
@@ -179815,7 +180154,45 @@ var ts;
|
|
|
179815
180154
|
setImmediate: function (x) { return setTimeout(x, 0); },
|
|
179816
180155
|
clearImmediate: function (handle) { return clearTimeout(handle); },
|
|
179817
180156
|
/* eslint-enable no-restricted-globals */
|
|
179818
|
-
|
|
180157
|
+
importServicePlugin: function (initialDir, moduleName) { return __awaiter(_this, void 0, void 0, function () {
|
|
180158
|
+
var packageRoot, packageJson, packageJsonResponse, e_1, browser, scriptPath, module_1, e_2;
|
|
180159
|
+
return __generator(this, function (_a) {
|
|
180160
|
+
switch (_a.label) {
|
|
180161
|
+
case 0:
|
|
180162
|
+
packageRoot = ts.combinePaths(initialDir, moduleName);
|
|
180163
|
+
_a.label = 1;
|
|
180164
|
+
case 1:
|
|
180165
|
+
_a.trys.push([1, 4, , 5]);
|
|
180166
|
+
return [4 /*yield*/, fetch(ts.combinePaths(packageRoot, "package.json"))];
|
|
180167
|
+
case 2:
|
|
180168
|
+
packageJsonResponse = _a.sent();
|
|
180169
|
+
return [4 /*yield*/, packageJsonResponse.json()];
|
|
180170
|
+
case 3:
|
|
180171
|
+
packageJson = _a.sent();
|
|
180172
|
+
return [3 /*break*/, 5];
|
|
180173
|
+
case 4:
|
|
180174
|
+
e_1 = _a.sent();
|
|
180175
|
+
return [2 /*return*/, { module: undefined, error: new Error("Could not load plugin. Could not load 'package.json'.") }];
|
|
180176
|
+
case 5:
|
|
180177
|
+
browser = packageJson.browser;
|
|
180178
|
+
if (!browser) {
|
|
180179
|
+
return [2 /*return*/, { module: undefined, error: new Error("Could not load plugin. No 'browser' field found in package.json.") }];
|
|
180180
|
+
}
|
|
180181
|
+
scriptPath = ts.combinePaths(packageRoot, browser);
|
|
180182
|
+
_a.label = 6;
|
|
180183
|
+
case 6:
|
|
180184
|
+
_a.trys.push([6, 8, , 9]);
|
|
180185
|
+
return [4 /*yield*/, dynamicImport(scriptPath)];
|
|
180186
|
+
case 7:
|
|
180187
|
+
module_1 = (_a.sent()).default;
|
|
180188
|
+
return [2 /*return*/, { module: module_1, error: undefined }];
|
|
180189
|
+
case 8:
|
|
180190
|
+
e_2 = _a.sent();
|
|
180191
|
+
return [2 /*return*/, { module: undefined, error: e_2 }];
|
|
180192
|
+
case 9: return [2 /*return*/];
|
|
180193
|
+
}
|
|
180194
|
+
});
|
|
180195
|
+
}); },
|
|
179819
180196
|
exit: ts.notImplemented,
|
|
179820
180197
|
// Debugging related
|
|
179821
180198
|
getEnvironmentVariable: returnEmptyString,
|