typescript 4.8.0-dev.20220612 → 4.8.0-dev.20220615
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dynamicImportCompat.js +25 -0
- package/lib/tsc.js +53 -12
- package/lib/tsserver.js +369 -28
- package/lib/tsserverlibrary.d.ts +10 -2
- package/lib/tsserverlibrary.js +308 -27
- package/lib/typescript.js +63 -13
- package/lib/typescriptServices.js +63 -13
- package/lib/typingsInstaller.js +63 -13
- 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-dev.
|
|
112
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220615";
|
|
104
113
|
/* @internal */
|
|
105
114
|
var Comparison;
|
|
106
115
|
(function (Comparison) {
|
|
@@ -8962,6 +8971,8 @@ var ts;
|
|
|
8962
8971
|
This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
|
|
8963
8972
|
An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
|
|
8964
8973
|
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'."),
|
|
8974
|
+
_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?"),
|
|
8975
|
+
We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
|
|
8965
8976
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
8966
8977
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
8967
8978
|
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}'."),
|
|
@@ -49193,6 +49204,7 @@ var ts;
|
|
|
49193
49204
|
var potentialNewTargetCollisions = [];
|
|
49194
49205
|
var potentialWeakMapSetCollisions = [];
|
|
49195
49206
|
var potentialReflectCollisions = [];
|
|
49207
|
+
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
49196
49208
|
var awaitedTypeStack = [];
|
|
49197
49209
|
var diagnostics = ts.createDiagnosticCollection();
|
|
49198
49210
|
var suggestionDiagnostics = ts.createDiagnosticCollection();
|
|
@@ -53700,15 +53712,22 @@ var ts;
|
|
|
53700
53712
|
context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
|
|
53701
53713
|
return parameterNode;
|
|
53702
53714
|
function cloneBindingName(node) {
|
|
53703
|
-
return
|
|
53704
|
-
function
|
|
53715
|
+
return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
|
|
53716
|
+
function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
|
|
53705
53717
|
if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
|
|
53706
53718
|
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
53707
53719
|
}
|
|
53708
|
-
var visited = ts.visitEachChild(node,
|
|
53720
|
+
var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
|
|
53709
53721
|
if (ts.isBindingElement(visited)) {
|
|
53710
|
-
visited
|
|
53711
|
-
|
|
53722
|
+
if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
|
|
53723
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
|
|
53724
|
+
/* propertyName*/ undefined, visited.propertyName,
|
|
53725
|
+
/*initializer*/ undefined);
|
|
53726
|
+
}
|
|
53727
|
+
else {
|
|
53728
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
|
|
53729
|
+
/*initializer*/ undefined);
|
|
53730
|
+
}
|
|
53712
53731
|
}
|
|
53713
53732
|
if (!ts.nodeIsSynthesized(visited)) {
|
|
53714
53733
|
visited = ts.factory.cloneNode(visited);
|
|
@@ -64918,7 +64937,7 @@ var ts;
|
|
|
64918
64937
|
return true;
|
|
64919
64938
|
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
64920
64939
|
return true;
|
|
64921
|
-
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
|
|
64940
|
+
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */)))
|
|
64922
64941
|
return true;
|
|
64923
64942
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
64924
64943
|
if (s & 1 /* Any */)
|
|
@@ -65621,7 +65640,7 @@ var ts;
|
|
|
65621
65640
|
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
65622
65641
|
}
|
|
65623
65642
|
if (target.flags & 2097152 /* Intersection */) {
|
|
65624
|
-
return typeRelatedToEachType(
|
|
65643
|
+
return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */);
|
|
65625
65644
|
}
|
|
65626
65645
|
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
65627
65646
|
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
@@ -68032,12 +68051,13 @@ var ts;
|
|
|
68032
68051
|
* with no call or construct signatures.
|
|
68033
68052
|
*/
|
|
68034
68053
|
function isObjectTypeWithInferableIndex(type) {
|
|
68054
|
+
var objectFlags = ts.getObjectFlags(type);
|
|
68035
68055
|
return type.flags & 2097152 /* Intersection */
|
|
68036
68056
|
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
68037
68057
|
: !!(type.symbol
|
|
68038
68058
|
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
68039
68059
|
&& !(type.symbol.flags & 32 /* Class */)
|
|
68040
|
-
&& !typeHasCallOrConstructSignatures(type)) || !!(
|
|
68060
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
68041
68061
|
}
|
|
68042
68062
|
function createSymbolWithType(source, type) {
|
|
68043
68063
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -82636,6 +82656,22 @@ var ts;
|
|
|
82636
82656
|
}
|
|
82637
82657
|
});
|
|
82638
82658
|
}
|
|
82659
|
+
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
82660
|
+
var _a;
|
|
82661
|
+
for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
|
|
82662
|
+
var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
|
|
82663
|
+
if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
|
|
82664
|
+
var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
|
|
82665
|
+
ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
|
|
82666
|
+
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));
|
|
82667
|
+
if (!wrappingDeclaration.type) {
|
|
82668
|
+
// entire parameter does not have type annotation, suggest adding an annotation
|
|
82669
|
+
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)));
|
|
82670
|
+
}
|
|
82671
|
+
diagnostics.add(diagnostic);
|
|
82672
|
+
}
|
|
82673
|
+
}
|
|
82674
|
+
}
|
|
82639
82675
|
function bindingNameText(name) {
|
|
82640
82676
|
switch (name.kind) {
|
|
82641
82677
|
case 79 /* Identifier */:
|
|
@@ -82937,6 +82973,17 @@ var ts;
|
|
|
82937
82973
|
}
|
|
82938
82974
|
}
|
|
82939
82975
|
if (ts.isBindingElement(node)) {
|
|
82976
|
+
if (node.propertyName &&
|
|
82977
|
+
ts.isIdentifier(node.name) &&
|
|
82978
|
+
ts.isParameterDeclaration(node) &&
|
|
82979
|
+
ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
|
|
82980
|
+
// type F = ({a: string}) => void;
|
|
82981
|
+
// ^^^^^^
|
|
82982
|
+
// variable renaming in function type notation is confusing,
|
|
82983
|
+
// so we forbid it even if noUnusedLocals is not enabled
|
|
82984
|
+
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
82985
|
+
return;
|
|
82986
|
+
}
|
|
82940
82987
|
if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
|
|
82941
82988
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
82942
82989
|
}
|
|
@@ -86400,6 +86447,7 @@ var ts;
|
|
|
86400
86447
|
ts.clear(potentialNewTargetCollisions);
|
|
86401
86448
|
ts.clear(potentialWeakMapSetCollisions);
|
|
86402
86449
|
ts.clear(potentialReflectCollisions);
|
|
86450
|
+
ts.clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
86403
86451
|
ts.forEach(node.statements, checkSourceElement);
|
|
86404
86452
|
checkSourceElement(node.endOfFileToken);
|
|
86405
86453
|
checkDeferredNodes(node);
|
|
@@ -86415,6 +86463,9 @@ var ts;
|
|
|
86415
86463
|
}
|
|
86416
86464
|
});
|
|
86417
86465
|
}
|
|
86466
|
+
if (!node.isDeclarationFile) {
|
|
86467
|
+
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
86468
|
+
}
|
|
86418
86469
|
});
|
|
86419
86470
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
86420
86471
|
!node.isDeclarationFile &&
|
|
@@ -109156,7 +109207,7 @@ var ts;
|
|
|
109156
109207
|
});
|
|
109157
109208
|
return ret;
|
|
109158
109209
|
}
|
|
109159
|
-
function
|
|
109210
|
+
function filterBindingPatternInitializersAndRenamings(name) {
|
|
109160
109211
|
if (name.kind === 79 /* Identifier */) {
|
|
109161
109212
|
return name;
|
|
109162
109213
|
}
|
|
@@ -109172,7 +109223,12 @@ var ts;
|
|
|
109172
109223
|
if (elem.kind === 227 /* OmittedExpression */) {
|
|
109173
109224
|
return elem;
|
|
109174
109225
|
}
|
|
109175
|
-
|
|
109226
|
+
if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
|
|
109227
|
+
// Unnecessary property renaming is forbidden in types, so remove renaming
|
|
109228
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken,
|
|
109229
|
+
/* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109230
|
+
}
|
|
109231
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109176
109232
|
}
|
|
109177
109233
|
}
|
|
109178
109234
|
function ensureParameter(p, modifierMask, type) {
|
|
@@ -109181,7 +109237,7 @@ var ts;
|
|
|
109181
109237
|
oldDiag = getSymbolAccessibilityDiagnostic;
|
|
109182
109238
|
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
|
|
109183
109239
|
}
|
|
109184
|
-
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken,
|
|
109240
|
+
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
|
|
109185
109241
|
ensureNoInitializer(p));
|
|
109186
109242
|
if (!suppressNewDiagnosticContexts) {
|
|
109187
109243
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
@@ -117324,6 +117380,7 @@ var ts;
|
|
|
117324
117380
|
ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
|
117325
117381
|
ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
|
|
117326
117382
|
ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
|
|
117383
|
+
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
117327
117384
|
]);
|
|
117328
117385
|
/**
|
|
117329
117386
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
@@ -122458,9 +122515,11 @@ var ts;
|
|
|
122458
122515
|
}
|
|
122459
122516
|
function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
|
|
122460
122517
|
ts.Debug.assert(!!resolution.refCount);
|
|
122518
|
+
var affectingLocations = resolution.affectingLocations;
|
|
122519
|
+
if (!affectingLocations.length)
|
|
122520
|
+
return;
|
|
122461
122521
|
if (addToResolutionsWithOnlyAffectingLocations)
|
|
122462
122522
|
resolutionsWithOnlyAffectingLocations.push(resolution);
|
|
122463
|
-
var affectingLocations = resolution.affectingLocations;
|
|
122464
122523
|
// Watch package json
|
|
122465
122524
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
122466
122525
|
var affectingLocation = affectingLocations_1[_i];
|
|
@@ -170394,6 +170453,38 @@ var ts;
|
|
|
170394
170453
|
}
|
|
170395
170454
|
return result.module;
|
|
170396
170455
|
};
|
|
170456
|
+
/*@internal*/
|
|
170457
|
+
Project.importServicePluginAsync = function (moduleName, initialDir, host, log, logErrors) {
|
|
170458
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170459
|
+
var resolvedPath, result, e_1, err;
|
|
170460
|
+
return __generator(this, function (_a) {
|
|
170461
|
+
switch (_a.label) {
|
|
170462
|
+
case 0:
|
|
170463
|
+
ts.Debug.assertIsDefined(host.importServicePlugin);
|
|
170464
|
+
resolvedPath = ts.combinePaths(initialDir, "node_modules");
|
|
170465
|
+
log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
|
|
170466
|
+
_a.label = 1;
|
|
170467
|
+
case 1:
|
|
170468
|
+
_a.trys.push([1, 3, , 4]);
|
|
170469
|
+
return [4 /*yield*/, host.importServicePlugin(resolvedPath, moduleName)];
|
|
170470
|
+
case 2:
|
|
170471
|
+
result = _a.sent();
|
|
170472
|
+
return [3 /*break*/, 4];
|
|
170473
|
+
case 3:
|
|
170474
|
+
e_1 = _a.sent();
|
|
170475
|
+
result = { module: undefined, error: e_1 };
|
|
170476
|
+
return [3 /*break*/, 4];
|
|
170477
|
+
case 4:
|
|
170478
|
+
if (result.error) {
|
|
170479
|
+
err = result.error.stack || result.error.message || JSON.stringify(result.error);
|
|
170480
|
+
(logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err);
|
|
170481
|
+
return [2 /*return*/, undefined];
|
|
170482
|
+
}
|
|
170483
|
+
return [2 /*return*/, result.module];
|
|
170484
|
+
}
|
|
170485
|
+
});
|
|
170486
|
+
});
|
|
170487
|
+
};
|
|
170397
170488
|
Project.prototype.isKnownTypesPackageName = function (name) {
|
|
170398
170489
|
return this.typingsCache.isKnownTypesPackageName(name);
|
|
170399
170490
|
};
|
|
@@ -171454,7 +171545,7 @@ var ts;
|
|
|
171454
171545
|
};
|
|
171455
171546
|
Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
|
|
171456
171547
|
var host = this.projectService.host;
|
|
171457
|
-
if (!host.require) {
|
|
171548
|
+
if (!host.require && !host.importServicePlugin) {
|
|
171458
171549
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
171459
171550
|
return;
|
|
171460
171551
|
}
|
|
@@ -171483,21 +171574,66 @@ var ts;
|
|
|
171483
171574
|
}
|
|
171484
171575
|
}
|
|
171485
171576
|
};
|
|
171486
|
-
|
|
171577
|
+
/**
|
|
171578
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'.
|
|
171579
|
+
*/
|
|
171580
|
+
/*@internal*/
|
|
171581
|
+
Project.prototype.beginEnablePluginSync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171487
171582
|
var _this = this;
|
|
171488
|
-
this.projectService.
|
|
171489
|
-
if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
|
|
171490
|
-
this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
|
|
171491
|
-
return;
|
|
171492
|
-
}
|
|
171493
|
-
var log = function (message) { return _this.projectService.logger.info(message); };
|
|
171583
|
+
ts.Debug.assertIsDefined(this.projectService.host.require);
|
|
171494
171584
|
var errorLogs;
|
|
171585
|
+
var log = function (message) { return _this.projectService.logger.info(message); };
|
|
171495
171586
|
var logError = function (message) {
|
|
171496
|
-
(errorLogs
|
|
171587
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171497
171588
|
};
|
|
171498
171589
|
var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
|
|
171499
171590
|
return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
|
|
171500
171591
|
});
|
|
171592
|
+
return { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs };
|
|
171593
|
+
};
|
|
171594
|
+
/**
|
|
171595
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`.
|
|
171596
|
+
*/
|
|
171597
|
+
/*@internal*/
|
|
171598
|
+
Project.prototype.beginEnablePluginAsync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171599
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171600
|
+
var errorLogs, log, logError, resolvedModule, _i, searchPaths_1, searchPath;
|
|
171601
|
+
var _this = this;
|
|
171602
|
+
return __generator(this, function (_a) {
|
|
171603
|
+
switch (_a.label) {
|
|
171604
|
+
case 0:
|
|
171605
|
+
ts.Debug.assertIsDefined(this.projectService.host.importServicePlugin);
|
|
171606
|
+
log = function (message) { return _this.projectService.logger.info(message); };
|
|
171607
|
+
logError = function (message) {
|
|
171608
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171609
|
+
};
|
|
171610
|
+
_i = 0, searchPaths_1 = searchPaths;
|
|
171611
|
+
_a.label = 1;
|
|
171612
|
+
case 1:
|
|
171613
|
+
if (!(_i < searchPaths_1.length)) return [3 /*break*/, 4];
|
|
171614
|
+
searchPath = searchPaths_1[_i];
|
|
171615
|
+
return [4 /*yield*/, Project.importServicePluginAsync(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError)];
|
|
171616
|
+
case 2:
|
|
171617
|
+
resolvedModule = (_a.sent());
|
|
171618
|
+
if (resolvedModule !== undefined) {
|
|
171619
|
+
return [3 /*break*/, 4];
|
|
171620
|
+
}
|
|
171621
|
+
_a.label = 3;
|
|
171622
|
+
case 3:
|
|
171623
|
+
_i++;
|
|
171624
|
+
return [3 /*break*/, 1];
|
|
171625
|
+
case 4: return [2 /*return*/, { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs }];
|
|
171626
|
+
}
|
|
171627
|
+
});
|
|
171628
|
+
});
|
|
171629
|
+
};
|
|
171630
|
+
/**
|
|
171631
|
+
* Performs the remaining steps of enabling a plugin after its module has been instantiated.
|
|
171632
|
+
*/
|
|
171633
|
+
/*@internal*/
|
|
171634
|
+
Project.prototype.endEnablePlugin = function (_a) {
|
|
171635
|
+
var _this = this;
|
|
171636
|
+
var pluginConfigEntry = _a.pluginConfigEntry, pluginConfigOverrides = _a.pluginConfigOverrides, resolvedModule = _a.resolvedModule, errorLogs = _a.errorLogs;
|
|
171501
171637
|
if (resolvedModule) {
|
|
171502
171638
|
var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
|
|
171503
171639
|
if (configurationOverride) {
|
|
@@ -171509,10 +171645,13 @@ var ts;
|
|
|
171509
171645
|
this.enableProxy(resolvedModule, pluginConfigEntry);
|
|
171510
171646
|
}
|
|
171511
171647
|
else {
|
|
171512
|
-
ts.forEach(errorLogs,
|
|
171648
|
+
ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); });
|
|
171513
171649
|
this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
|
|
171514
171650
|
}
|
|
171515
171651
|
};
|
|
171652
|
+
Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171653
|
+
this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
171654
|
+
};
|
|
171516
171655
|
Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) {
|
|
171517
171656
|
try {
|
|
171518
171657
|
if (typeof pluginModuleFactory !== "function") {
|
|
@@ -172164,7 +172303,7 @@ var ts;
|
|
|
172164
172303
|
/*@internal*/
|
|
172165
172304
|
ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
|
|
172166
172305
|
var host = this.projectService.host;
|
|
172167
|
-
if (!host.require) {
|
|
172306
|
+
if (!host.require && !host.importServicePlugin) {
|
|
172168
172307
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
172169
172308
|
return;
|
|
172170
172309
|
}
|
|
@@ -172183,7 +172322,7 @@ var ts;
|
|
|
172183
172322
|
this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
172184
172323
|
}
|
|
172185
172324
|
}
|
|
172186
|
-
this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172325
|
+
return this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172187
172326
|
};
|
|
172188
172327
|
/**
|
|
172189
172328
|
* Get the errors that dont have any file name associated
|
|
@@ -175605,6 +175744,147 @@ var ts;
|
|
|
175605
175744
|
}
|
|
175606
175745
|
return false;
|
|
175607
175746
|
};
|
|
175747
|
+
/*@internal*/
|
|
175748
|
+
ProjectService.prototype.requestEnablePlugin = function (project, pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
175749
|
+
var _a;
|
|
175750
|
+
if (!this.host.importServicePlugin && !this.host.require) {
|
|
175751
|
+
this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
175752
|
+
return;
|
|
175753
|
+
}
|
|
175754
|
+
this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
|
|
175755
|
+
if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
|
|
175756
|
+
this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
|
|
175757
|
+
return;
|
|
175758
|
+
}
|
|
175759
|
+
// If the host supports dynamic import, begin enabling the plugin asynchronously.
|
|
175760
|
+
if (this.host.importServicePlugin) {
|
|
175761
|
+
var importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
175762
|
+
(_a = this.pendingPluginEnablements) !== null && _a !== void 0 ? _a : (this.pendingPluginEnablements = new ts.Map());
|
|
175763
|
+
var promises = this.pendingPluginEnablements.get(project);
|
|
175764
|
+
if (!promises)
|
|
175765
|
+
this.pendingPluginEnablements.set(project, promises = []);
|
|
175766
|
+
promises.push(importPromise);
|
|
175767
|
+
return;
|
|
175768
|
+
}
|
|
175769
|
+
// Otherwise, load the plugin using `require`
|
|
175770
|
+
project.endEnablePlugin(project.beginEnablePluginSync(pluginConfigEntry, searchPaths, pluginConfigOverrides));
|
|
175771
|
+
};
|
|
175772
|
+
/* @internal */
|
|
175773
|
+
ProjectService.prototype.hasNewPluginEnablementRequests = function () {
|
|
175774
|
+
return !!this.pendingPluginEnablements;
|
|
175775
|
+
};
|
|
175776
|
+
/* @internal */
|
|
175777
|
+
ProjectService.prototype.hasPendingPluginEnablements = function () {
|
|
175778
|
+
return !!this.currentPluginEnablementPromise;
|
|
175779
|
+
};
|
|
175780
|
+
/**
|
|
175781
|
+
* Waits for any ongoing plugin enablement requests to complete.
|
|
175782
|
+
*/
|
|
175783
|
+
/* @internal */
|
|
175784
|
+
ProjectService.prototype.waitForPendingPlugins = function () {
|
|
175785
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175786
|
+
return __generator(this, function (_a) {
|
|
175787
|
+
switch (_a.label) {
|
|
175788
|
+
case 0:
|
|
175789
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
175790
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
175791
|
+
case 1:
|
|
175792
|
+
_a.sent();
|
|
175793
|
+
return [3 /*break*/, 0];
|
|
175794
|
+
case 2: return [2 /*return*/];
|
|
175795
|
+
}
|
|
175796
|
+
});
|
|
175797
|
+
});
|
|
175798
|
+
};
|
|
175799
|
+
/**
|
|
175800
|
+
* Starts enabling any requested plugins without waiting for the result.
|
|
175801
|
+
*/
|
|
175802
|
+
/* @internal */
|
|
175803
|
+
ProjectService.prototype.enableRequestedPlugins = function () {
|
|
175804
|
+
if (this.pendingPluginEnablements) {
|
|
175805
|
+
void this.enableRequestedPluginsAsync();
|
|
175806
|
+
}
|
|
175807
|
+
};
|
|
175808
|
+
ProjectService.prototype.enableRequestedPluginsAsync = function () {
|
|
175809
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175810
|
+
var entries;
|
|
175811
|
+
return __generator(this, function (_a) {
|
|
175812
|
+
switch (_a.label) {
|
|
175813
|
+
case 0:
|
|
175814
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
175815
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
175816
|
+
return [4 /*yield*/, this.waitForPendingPlugins()];
|
|
175817
|
+
case 1:
|
|
175818
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
175819
|
+
_a.sent();
|
|
175820
|
+
_a.label = 2;
|
|
175821
|
+
case 2:
|
|
175822
|
+
// Skip if there are no new plugin enablement requests
|
|
175823
|
+
if (!this.pendingPluginEnablements) {
|
|
175824
|
+
return [2 /*return*/];
|
|
175825
|
+
}
|
|
175826
|
+
entries = ts.arrayFrom(this.pendingPluginEnablements.entries());
|
|
175827
|
+
this.pendingPluginEnablements = undefined;
|
|
175828
|
+
// Start processing the requests, keeping track of the promise for the operation so that
|
|
175829
|
+
// project consumers can potentially wait for the plugins to load.
|
|
175830
|
+
this.currentPluginEnablementPromise = this.enableRequestedPluginsWorker(entries);
|
|
175831
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
175832
|
+
case 3:
|
|
175833
|
+
_a.sent();
|
|
175834
|
+
return [2 /*return*/];
|
|
175835
|
+
}
|
|
175836
|
+
});
|
|
175837
|
+
});
|
|
175838
|
+
};
|
|
175839
|
+
ProjectService.prototype.enableRequestedPluginsWorker = function (pendingPlugins) {
|
|
175840
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175841
|
+
var _this = this;
|
|
175842
|
+
return __generator(this, function (_a) {
|
|
175843
|
+
switch (_a.label) {
|
|
175844
|
+
case 0:
|
|
175845
|
+
// This should only be called from `enableRequestedPluginsAsync`, which ensures this precondition is met.
|
|
175846
|
+
ts.Debug.assert(this.currentPluginEnablementPromise === undefined);
|
|
175847
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
175848
|
+
// on a project with many plugins.
|
|
175849
|
+
return [4 /*yield*/, Promise.all(ts.map(pendingPlugins, function (_a) {
|
|
175850
|
+
var project = _a[0], promises = _a[1];
|
|
175851
|
+
return _this.enableRequestedPluginsForProjectAsync(project, promises);
|
|
175852
|
+
}))];
|
|
175853
|
+
case 1:
|
|
175854
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
175855
|
+
// on a project with many plugins.
|
|
175856
|
+
_a.sent();
|
|
175857
|
+
// Clear the pending operation and notify the client that projects have been updated.
|
|
175858
|
+
this.currentPluginEnablementPromise = undefined;
|
|
175859
|
+
this.sendProjectsUpdatedInBackgroundEvent();
|
|
175860
|
+
return [2 /*return*/];
|
|
175861
|
+
}
|
|
175862
|
+
});
|
|
175863
|
+
});
|
|
175864
|
+
};
|
|
175865
|
+
ProjectService.prototype.enableRequestedPluginsForProjectAsync = function (project, promises) {
|
|
175866
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175867
|
+
var results, _i, results_1, result;
|
|
175868
|
+
return __generator(this, function (_a) {
|
|
175869
|
+
switch (_a.label) {
|
|
175870
|
+
case 0: return [4 /*yield*/, Promise.all(promises)];
|
|
175871
|
+
case 1:
|
|
175872
|
+
results = _a.sent();
|
|
175873
|
+
if (project.isClosed()) {
|
|
175874
|
+
// project is not alive, so don't enable plugins.
|
|
175875
|
+
return [2 /*return*/];
|
|
175876
|
+
}
|
|
175877
|
+
for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
|
|
175878
|
+
result = results_1[_i];
|
|
175879
|
+
project.endEnablePlugin(result);
|
|
175880
|
+
}
|
|
175881
|
+
// Plugins may have modified external files, so mark the project as dirty.
|
|
175882
|
+
this.delayUpdateProjectGraph(project);
|
|
175883
|
+
return [2 /*return*/];
|
|
175884
|
+
}
|
|
175885
|
+
});
|
|
175886
|
+
});
|
|
175887
|
+
};
|
|
175608
175888
|
ProjectService.prototype.configurePlugin = function (args) {
|
|
175609
175889
|
// For any projects that already have the plugin loaded, configure the plugin
|
|
175610
175890
|
this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); });
|
|
@@ -176433,7 +176713,6 @@ var ts;
|
|
|
176433
176713
|
server.CommandNames.OrganizeImportsFull,
|
|
176434
176714
|
server.CommandNames.GetEditsForFileRename,
|
|
176435
176715
|
server.CommandNames.GetEditsForFileRenameFull,
|
|
176436
|
-
server.CommandNames.ConfigurePlugin,
|
|
176437
176716
|
server.CommandNames.PrepareCallHierarchy,
|
|
176438
176717
|
server.CommandNames.ProvideCallHierarchyIncomingCalls,
|
|
176439
176718
|
server.CommandNames.ProvideCallHierarchyOutgoingCalls,
|
|
@@ -178701,7 +178980,9 @@ var ts;
|
|
|
178701
178980
|
Session.prototype.executeCommand = function (request) {
|
|
178702
178981
|
var handler = this.handlers.get(request.command);
|
|
178703
178982
|
if (handler) {
|
|
178704
|
-
|
|
178983
|
+
var response = this.executeWithRequestId(request.seq, function () { return handler(request); });
|
|
178984
|
+
this.projectService.enableRequestedPlugins();
|
|
178985
|
+
return response;
|
|
178705
178986
|
}
|
|
178706
178987
|
else {
|
|
178707
178988
|
this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err);
|
|
@@ -179615,6 +179896,8 @@ var ts;
|
|
|
179615
179896
|
})(server = ts.server || (ts.server = {}));
|
|
179616
179897
|
})(ts || (ts = {}));
|
|
179617
179898
|
/*@internal*/
|
|
179899
|
+
/// <reference lib="dom" />
|
|
179900
|
+
/// <reference lib="webworker.importscripts" />
|
|
179618
179901
|
var ts;
|
|
179619
179902
|
(function (ts) {
|
|
179620
179903
|
var server;
|
|
@@ -179720,11 +180003,31 @@ var ts;
|
|
|
179720
180003
|
return MainProcessLogger;
|
|
179721
180004
|
}(BaseLogger));
|
|
179722
180005
|
server.MainProcessLogger = MainProcessLogger;
|
|
180006
|
+
// Attempt to load `dynamicImport`
|
|
180007
|
+
if (typeof importScripts === "function") {
|
|
180008
|
+
try {
|
|
180009
|
+
// NOTE: importScripts is synchronous
|
|
180010
|
+
importScripts("dynamicImportCompat.js");
|
|
180011
|
+
}
|
|
180012
|
+
catch (_a) {
|
|
180013
|
+
// ignored
|
|
180014
|
+
}
|
|
180015
|
+
}
|
|
179723
180016
|
function createWebSystem(host, args, getExecutingFilePath) {
|
|
180017
|
+
var _this = this;
|
|
179724
180018
|
var returnEmptyString = function () { return ""; };
|
|
179725
180019
|
var getExecutingDirectoryPath = ts.memoize(function () { return ts.memoize(function () { return ts.ensureTrailingDirectorySeparator(ts.getDirectoryPath(getExecutingFilePath())); }); });
|
|
179726
180020
|
// Later we could map ^memfs:/ to do something special if we want to enable more functionality like module resolution or something like that
|
|
179727
180021
|
var getWebPath = function (path) { return ts.startsWith(path, ts.directorySeparator) ? path.replace(ts.directorySeparator, getExecutingDirectoryPath()) : undefined; };
|
|
180022
|
+
var dynamicImport = function (id) { return __awaiter(_this, void 0, void 0, function () {
|
|
180023
|
+
return __generator(this, function (_a) {
|
|
180024
|
+
// Use syntactic dynamic import first, if available
|
|
180025
|
+
if (server.dynamicImport) {
|
|
180026
|
+
return [2 /*return*/, server.dynamicImport(id)];
|
|
180027
|
+
}
|
|
180028
|
+
throw new Error("Dynamic import not implemented");
|
|
180029
|
+
});
|
|
180030
|
+
}); };
|
|
179728
180031
|
return {
|
|
179729
180032
|
args: args,
|
|
179730
180033
|
newLine: "\r\n",
|
|
@@ -179750,7 +180053,45 @@ var ts;
|
|
|
179750
180053
|
setImmediate: function (x) { return setTimeout(x, 0); },
|
|
179751
180054
|
clearImmediate: function (handle) { return clearTimeout(handle); },
|
|
179752
180055
|
/* eslint-enable no-restricted-globals */
|
|
179753
|
-
|
|
180056
|
+
importServicePlugin: function (initialDir, moduleName) { return __awaiter(_this, void 0, void 0, function () {
|
|
180057
|
+
var packageRoot, packageJson, packageJsonResponse, e_1, browser, scriptPath, module_1, e_2;
|
|
180058
|
+
return __generator(this, function (_a) {
|
|
180059
|
+
switch (_a.label) {
|
|
180060
|
+
case 0:
|
|
180061
|
+
packageRoot = ts.combinePaths(initialDir, moduleName);
|
|
180062
|
+
_a.label = 1;
|
|
180063
|
+
case 1:
|
|
180064
|
+
_a.trys.push([1, 4, , 5]);
|
|
180065
|
+
return [4 /*yield*/, fetch(ts.combinePaths(packageRoot, "package.json"))];
|
|
180066
|
+
case 2:
|
|
180067
|
+
packageJsonResponse = _a.sent();
|
|
180068
|
+
return [4 /*yield*/, packageJsonResponse.json()];
|
|
180069
|
+
case 3:
|
|
180070
|
+
packageJson = _a.sent();
|
|
180071
|
+
return [3 /*break*/, 5];
|
|
180072
|
+
case 4:
|
|
180073
|
+
e_1 = _a.sent();
|
|
180074
|
+
return [2 /*return*/, { module: undefined, error: new Error("Could not load plugin. Could not load 'package.json'.") }];
|
|
180075
|
+
case 5:
|
|
180076
|
+
browser = packageJson.browser;
|
|
180077
|
+
if (!browser) {
|
|
180078
|
+
return [2 /*return*/, { module: undefined, error: new Error("Could not load plugin. No 'browser' field found in package.json.") }];
|
|
180079
|
+
}
|
|
180080
|
+
scriptPath = ts.combinePaths(packageRoot, browser);
|
|
180081
|
+
_a.label = 6;
|
|
180082
|
+
case 6:
|
|
180083
|
+
_a.trys.push([6, 8, , 9]);
|
|
180084
|
+
return [4 /*yield*/, dynamicImport(scriptPath)];
|
|
180085
|
+
case 7:
|
|
180086
|
+
module_1 = (_a.sent()).default;
|
|
180087
|
+
return [2 /*return*/, { module: module_1, error: undefined }];
|
|
180088
|
+
case 8:
|
|
180089
|
+
e_2 = _a.sent();
|
|
180090
|
+
return [2 /*return*/, { module: undefined, error: e_2 }];
|
|
180091
|
+
case 9: return [2 /*return*/];
|
|
180092
|
+
}
|
|
180093
|
+
});
|
|
180094
|
+
}); },
|
|
179754
180095
|
exit: ts.notImplemented,
|
|
179755
180096
|
// Debugging related
|
|
179756
180097
|
getEnvironmentVariable: returnEmptyString,
|