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/tsserverlibrary.d.ts
CHANGED
|
@@ -6980,7 +6980,7 @@ declare namespace ts.server {
|
|
|
6980
6980
|
compressionKind: string;
|
|
6981
6981
|
data: any;
|
|
6982
6982
|
}
|
|
6983
|
-
type
|
|
6983
|
+
type ModuleImportResult = {
|
|
6984
6984
|
module: {};
|
|
6985
6985
|
error: undefined;
|
|
6986
6986
|
} | {
|
|
@@ -6990,6 +6990,8 @@ declare namespace ts.server {
|
|
|
6990
6990
|
message?: string;
|
|
6991
6991
|
};
|
|
6992
6992
|
};
|
|
6993
|
+
/** @deprecated Use {@link ModuleImportResult} instead. */
|
|
6994
|
+
type RequireResult = ModuleImportResult;
|
|
6993
6995
|
interface ServerHost extends System {
|
|
6994
6996
|
watchFile(path: string, callback: FileWatcherCallback, pollingInterval?: number, options?: WatchOptions): FileWatcher;
|
|
6995
6997
|
watchDirectory(path: string, callback: DirectoryWatcherCallback, recursive?: boolean, options?: WatchOptions): FileWatcher;
|
|
@@ -6999,7 +7001,8 @@ declare namespace ts.server {
|
|
|
6999
7001
|
clearImmediate(timeoutId: any): void;
|
|
7000
7002
|
gc?(): void;
|
|
7001
7003
|
trace?(s: string): void;
|
|
7002
|
-
require?(initialPath: string, moduleName: string):
|
|
7004
|
+
require?(initialPath: string, moduleName: string): ModuleImportResult;
|
|
7005
|
+
importServicePlugin?(root: string, moduleName: string): Promise<ModuleImportResult>;
|
|
7003
7006
|
}
|
|
7004
7007
|
}
|
|
7005
7008
|
declare namespace ts.server {
|
|
@@ -10449,6 +10452,8 @@ declare namespace ts.server {
|
|
|
10449
10452
|
/** Tracks projects that we have already sent telemetry for. */
|
|
10450
10453
|
private readonly seenProjects;
|
|
10451
10454
|
private performanceEventHandler?;
|
|
10455
|
+
private pendingPluginEnablements?;
|
|
10456
|
+
private currentPluginEnablementPromise?;
|
|
10452
10457
|
constructor(opts: ProjectServiceOptions);
|
|
10453
10458
|
toPath(fileName: string): Path;
|
|
10454
10459
|
private loadTypesMap;
|
|
@@ -10608,6 +10613,9 @@ declare namespace ts.server {
|
|
|
10608
10613
|
applySafeList(proj: protocol.ExternalProject): NormalizedPath[];
|
|
10609
10614
|
openExternalProject(proj: protocol.ExternalProject): void;
|
|
10610
10615
|
hasDeferredExtension(): boolean;
|
|
10616
|
+
private enableRequestedPluginsAsync;
|
|
10617
|
+
private enableRequestedPluginsWorker;
|
|
10618
|
+
private enableRequestedPluginsForProjectAsync;
|
|
10611
10619
|
configurePlugin(args: protocol.ConfigurePluginRequestArguments): void;
|
|
10612
10620
|
}
|
|
10613
10621
|
export {};
|
package/lib/tsserverlibrary.js
CHANGED
|
@@ -91,6 +91,15 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
91
91
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
92
92
|
};
|
|
93
93
|
})();
|
|
94
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
95
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
96
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
97
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
98
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
99
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
100
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
101
|
+
});
|
|
102
|
+
};
|
|
94
103
|
/* @internal */
|
|
95
104
|
var ts;
|
|
96
105
|
(function (ts) {
|
|
@@ -294,7 +303,7 @@ var ts;
|
|
|
294
303
|
// The following is baselined as a literal template type without intervention
|
|
295
304
|
/** The version of the TypeScript compiler release */
|
|
296
305
|
// eslint-disable-next-line @typescript-eslint/no-inferrable-types
|
|
297
|
-
ts.version = ts.versionMajorMinor + ".0-dev.
|
|
306
|
+
ts.version = ts.versionMajorMinor + ".0-dev.20220615";
|
|
298
307
|
/* @internal */
|
|
299
308
|
var Comparison;
|
|
300
309
|
(function (Comparison) {
|
|
@@ -9156,6 +9165,8 @@ var ts;
|
|
|
9156
9165
|
This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value: diag(2839, ts.DiagnosticCategory.Error, "This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value_2839", "This condition will always return '{0}' since JavaScript compares objects by reference, not value."),
|
|
9157
9166
|
An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_classes: diag(2840, ts.DiagnosticCategory.Error, "An_interface_cannot_extend_a_primitive_type_like_0_an_interface_can_only_extend_named_types_and_clas_2840", "An interface cannot extend a primitive type like '{0}'; an interface can only extend named types and classes"),
|
|
9158
9167
|
The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_feature_Use_nightly_TypeScript_to_silence_this_error_Try_updating_with_npm_install_D_typescript_next: diag(2841, ts.DiagnosticCategory.Error, "The_type_of_this_expression_cannot_be_named_without_a_resolution_mode_assertion_which_is_an_unstable_2841", "The type of this expression cannot be named without a 'resolution-mode' assertion, which is an unstable feature. Use nightly TypeScript to silence this error. Try updating with 'npm install -D typescript@next'."),
|
|
9168
|
+
_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation: diag(2842, ts.DiagnosticCategory.Error, "_0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation_2842", "'{0}' is an unused renaming of '{1}'. Did you intend to use it as a type annotation?"),
|
|
9169
|
+
We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here: diag(2843, ts.DiagnosticCategory.Error, "We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here_2843", "We can only write a type for '{0}' by adding a type for the entire parameter here."),
|
|
9159
9170
|
Import_declaration_0_is_using_private_name_1: diag(4000, ts.DiagnosticCategory.Error, "Import_declaration_0_is_using_private_name_1_4000", "Import declaration '{0}' is using private name '{1}'."),
|
|
9160
9171
|
Type_parameter_0_of_exported_class_has_or_is_using_private_name_1: diag(4002, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_class_has_or_is_using_private_name_1_4002", "Type parameter '{0}' of exported class has or is using private name '{1}'."),
|
|
9161
9172
|
Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1: diag(4004, ts.DiagnosticCategory.Error, "Type_parameter_0_of_exported_interface_has_or_is_using_private_name_1_4004", "Type parameter '{0}' of exported interface has or is using private name '{1}'."),
|
|
@@ -49387,6 +49398,7 @@ var ts;
|
|
|
49387
49398
|
var potentialNewTargetCollisions = [];
|
|
49388
49399
|
var potentialWeakMapSetCollisions = [];
|
|
49389
49400
|
var potentialReflectCollisions = [];
|
|
49401
|
+
var potentialUnusedRenamedBindingElementsInTypes = [];
|
|
49390
49402
|
var awaitedTypeStack = [];
|
|
49391
49403
|
var diagnostics = ts.createDiagnosticCollection();
|
|
49392
49404
|
var suggestionDiagnostics = ts.createDiagnosticCollection();
|
|
@@ -53894,15 +53906,22 @@ var ts;
|
|
|
53894
53906
|
context.approximateLength += ts.symbolName(parameterSymbol).length + 3;
|
|
53895
53907
|
return parameterNode;
|
|
53896
53908
|
function cloneBindingName(node) {
|
|
53897
|
-
return
|
|
53898
|
-
function
|
|
53909
|
+
return elideInitializerAndPropertyRenamingAndSetEmitFlags(node);
|
|
53910
|
+
function elideInitializerAndPropertyRenamingAndSetEmitFlags(node) {
|
|
53899
53911
|
if (context.tracker.trackSymbol && ts.isComputedPropertyName(node) && isLateBindableName(node)) {
|
|
53900
53912
|
trackComputedName(node.expression, context.enclosingDeclaration, context);
|
|
53901
53913
|
}
|
|
53902
|
-
var visited = ts.visitEachChild(node,
|
|
53914
|
+
var visited = ts.visitEachChild(node, elideInitializerAndPropertyRenamingAndSetEmitFlags, ts.nullTransformationContext, /*nodesVisitor*/ undefined, elideInitializerAndPropertyRenamingAndSetEmitFlags);
|
|
53903
53915
|
if (ts.isBindingElement(visited)) {
|
|
53904
|
-
visited
|
|
53905
|
-
|
|
53916
|
+
if (visited.propertyName && ts.isIdentifier(visited.propertyName) && ts.isIdentifier(visited.name)) {
|
|
53917
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken,
|
|
53918
|
+
/* propertyName*/ undefined, visited.propertyName,
|
|
53919
|
+
/*initializer*/ undefined);
|
|
53920
|
+
}
|
|
53921
|
+
else {
|
|
53922
|
+
visited = ts.factory.updateBindingElement(visited, visited.dotDotDotToken, visited.propertyName, visited.name,
|
|
53923
|
+
/*initializer*/ undefined);
|
|
53924
|
+
}
|
|
53906
53925
|
}
|
|
53907
53926
|
if (!ts.nodeIsSynthesized(visited)) {
|
|
53908
53927
|
visited = ts.factory.cloneNode(visited);
|
|
@@ -65112,7 +65131,7 @@ var ts;
|
|
|
65112
65131
|
return true;
|
|
65113
65132
|
if (s & 65536 /* Null */ && (!strictNullChecks && !(t & 3145728 /* UnionOrIntersection */) || t & 65536 /* Null */))
|
|
65114
65133
|
return true;
|
|
65115
|
-
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source)))
|
|
65134
|
+
if (s & 524288 /* Object */ && t & 67108864 /* NonPrimitive */ && !(relation === strictSubtypeRelation && isEmptyAnonymousObjectType(source) && !(ts.getObjectFlags(source) & 8192 /* FreshLiteral */)))
|
|
65116
65135
|
return true;
|
|
65117
65136
|
if (relation === assignableRelation || relation === comparableRelation) {
|
|
65118
65137
|
if (s & 1 /* Any */)
|
|
@@ -65815,7 +65834,7 @@ var ts;
|
|
|
65815
65834
|
return typeRelatedToSomeType(getRegularTypeOfObjectLiteral(source), target, reportErrors && !(source.flags & 131068 /* Primitive */) && !(target.flags & 131068 /* Primitive */));
|
|
65816
65835
|
}
|
|
65817
65836
|
if (target.flags & 2097152 /* Intersection */) {
|
|
65818
|
-
return typeRelatedToEachType(
|
|
65837
|
+
return typeRelatedToEachType(source, target, reportErrors, 2 /* Target */);
|
|
65819
65838
|
}
|
|
65820
65839
|
// Source is an intersection. For the comparable relation, if the target is a primitive type we hoist the
|
|
65821
65840
|
// constraints of all non-primitive types in the source into a new intersection. We do this because the
|
|
@@ -68226,12 +68245,13 @@ var ts;
|
|
|
68226
68245
|
* with no call or construct signatures.
|
|
68227
68246
|
*/
|
|
68228
68247
|
function isObjectTypeWithInferableIndex(type) {
|
|
68248
|
+
var objectFlags = ts.getObjectFlags(type);
|
|
68229
68249
|
return type.flags & 2097152 /* Intersection */
|
|
68230
68250
|
? ts.every(type.types, isObjectTypeWithInferableIndex)
|
|
68231
68251
|
: !!(type.symbol
|
|
68232
68252
|
&& (type.symbol.flags & (4096 /* ObjectLiteral */ | 2048 /* TypeLiteral */ | 384 /* Enum */ | 512 /* ValueModule */)) !== 0
|
|
68233
68253
|
&& !(type.symbol.flags & 32 /* Class */)
|
|
68234
|
-
&& !typeHasCallOrConstructSignatures(type)) || !!(
|
|
68254
|
+
&& !typeHasCallOrConstructSignatures(type)) || !!(objectFlags & 4194304 /* ObjectRestType */) || !!(objectFlags & 1024 /* ReverseMapped */ && isObjectTypeWithInferableIndex(type.source));
|
|
68235
68255
|
}
|
|
68236
68256
|
function createSymbolWithType(source, type) {
|
|
68237
68257
|
var symbol = createSymbol(source.flags, source.escapedName, ts.getCheckFlags(source) & 8 /* Readonly */);
|
|
@@ -82830,6 +82850,22 @@ var ts;
|
|
|
82830
82850
|
}
|
|
82831
82851
|
});
|
|
82832
82852
|
}
|
|
82853
|
+
function checkPotentialUncheckedRenamedBindingElementsInTypes() {
|
|
82854
|
+
var _a;
|
|
82855
|
+
for (var _i = 0, potentialUnusedRenamedBindingElementsInTypes_1 = potentialUnusedRenamedBindingElementsInTypes; _i < potentialUnusedRenamedBindingElementsInTypes_1.length; _i++) {
|
|
82856
|
+
var node = potentialUnusedRenamedBindingElementsInTypes_1[_i];
|
|
82857
|
+
if (!((_a = getSymbolOfNode(node)) === null || _a === void 0 ? void 0 : _a.isReferenced)) {
|
|
82858
|
+
var wrappingDeclaration = ts.walkUpBindingElementsAndPatterns(node);
|
|
82859
|
+
ts.Debug.assert(ts.isParameterDeclaration(wrappingDeclaration), "Only parameter declaration should be checked here");
|
|
82860
|
+
var diagnostic = ts.createDiagnosticForNode(node.name, ts.Diagnostics._0_is_an_unused_renaming_of_1_Did_you_intend_to_use_it_as_a_type_annotation, ts.declarationNameToString(node.name), ts.declarationNameToString(node.propertyName));
|
|
82861
|
+
if (!wrappingDeclaration.type) {
|
|
82862
|
+
// entire parameter does not have type annotation, suggest adding an annotation
|
|
82863
|
+
ts.addRelatedInfo(diagnostic, ts.createFileDiagnostic(ts.getSourceFileOfNode(wrappingDeclaration), wrappingDeclaration.end, 1, ts.Diagnostics.We_can_only_write_a_type_for_0_by_adding_a_type_for_the_entire_parameter_here, ts.declarationNameToString(node.propertyName)));
|
|
82864
|
+
}
|
|
82865
|
+
diagnostics.add(diagnostic);
|
|
82866
|
+
}
|
|
82867
|
+
}
|
|
82868
|
+
}
|
|
82833
82869
|
function bindingNameText(name) {
|
|
82834
82870
|
switch (name.kind) {
|
|
82835
82871
|
case 79 /* Identifier */:
|
|
@@ -83131,6 +83167,17 @@ var ts;
|
|
|
83131
83167
|
}
|
|
83132
83168
|
}
|
|
83133
83169
|
if (ts.isBindingElement(node)) {
|
|
83170
|
+
if (node.propertyName &&
|
|
83171
|
+
ts.isIdentifier(node.name) &&
|
|
83172
|
+
ts.isParameterDeclaration(node) &&
|
|
83173
|
+
ts.nodeIsMissing(ts.getContainingFunction(node).body)) {
|
|
83174
|
+
// type F = ({a: string}) => void;
|
|
83175
|
+
// ^^^^^^
|
|
83176
|
+
// variable renaming in function type notation is confusing,
|
|
83177
|
+
// so we forbid it even if noUnusedLocals is not enabled
|
|
83178
|
+
potentialUnusedRenamedBindingElementsInTypes.push(node);
|
|
83179
|
+
return;
|
|
83180
|
+
}
|
|
83134
83181
|
if (ts.isObjectBindingPattern(node.parent) && node.dotDotDotToken && languageVersion < 5 /* ES2018 */) {
|
|
83135
83182
|
checkExternalEmitHelpers(node, 4 /* Rest */);
|
|
83136
83183
|
}
|
|
@@ -86594,6 +86641,7 @@ var ts;
|
|
|
86594
86641
|
ts.clear(potentialNewTargetCollisions);
|
|
86595
86642
|
ts.clear(potentialWeakMapSetCollisions);
|
|
86596
86643
|
ts.clear(potentialReflectCollisions);
|
|
86644
|
+
ts.clear(potentialUnusedRenamedBindingElementsInTypes);
|
|
86597
86645
|
ts.forEach(node.statements, checkSourceElement);
|
|
86598
86646
|
checkSourceElement(node.endOfFileToken);
|
|
86599
86647
|
checkDeferredNodes(node);
|
|
@@ -86609,6 +86657,9 @@ var ts;
|
|
|
86609
86657
|
}
|
|
86610
86658
|
});
|
|
86611
86659
|
}
|
|
86660
|
+
if (!node.isDeclarationFile) {
|
|
86661
|
+
checkPotentialUncheckedRenamedBindingElementsInTypes();
|
|
86662
|
+
}
|
|
86612
86663
|
});
|
|
86613
86664
|
if (compilerOptions.importsNotUsedAsValues === 2 /* Error */ &&
|
|
86614
86665
|
!node.isDeclarationFile &&
|
|
@@ -109350,7 +109401,7 @@ var ts;
|
|
|
109350
109401
|
});
|
|
109351
109402
|
return ret;
|
|
109352
109403
|
}
|
|
109353
|
-
function
|
|
109404
|
+
function filterBindingPatternInitializersAndRenamings(name) {
|
|
109354
109405
|
if (name.kind === 79 /* Identifier */) {
|
|
109355
109406
|
return name;
|
|
109356
109407
|
}
|
|
@@ -109366,7 +109417,12 @@ var ts;
|
|
|
109366
109417
|
if (elem.kind === 227 /* OmittedExpression */) {
|
|
109367
109418
|
return elem;
|
|
109368
109419
|
}
|
|
109369
|
-
|
|
109420
|
+
if (elem.propertyName && ts.isIdentifier(elem.propertyName) && ts.isIdentifier(elem.name) && !elem.symbol.isReferenced) {
|
|
109421
|
+
// Unnecessary property renaming is forbidden in types, so remove renaming
|
|
109422
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken,
|
|
109423
|
+
/* propertyName */ undefined, elem.propertyName, shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109424
|
+
}
|
|
109425
|
+
return factory.updateBindingElement(elem, elem.dotDotDotToken, elem.propertyName, filterBindingPatternInitializersAndRenamings(elem.name), shouldPrintWithInitializer(elem) ? elem.initializer : undefined);
|
|
109370
109426
|
}
|
|
109371
109427
|
}
|
|
109372
109428
|
function ensureParameter(p, modifierMask, type) {
|
|
@@ -109375,7 +109431,7 @@ var ts;
|
|
|
109375
109431
|
oldDiag = getSymbolAccessibilityDiagnostic;
|
|
109376
109432
|
getSymbolAccessibilityDiagnostic = ts.createGetSymbolAccessibilityDiagnosticForNode(p);
|
|
109377
109433
|
}
|
|
109378
|
-
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken,
|
|
109434
|
+
var newParam = factory.updateParameterDeclaration(p, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializersAndRenamings(p.name), resolver.isOptionalParameter(p) ? (p.questionToken || factory.createToken(57 /* QuestionToken */)) : undefined, ensureType(p, type || p.type, /*ignorePrivate*/ true), // Ignore private param props, since this type is going straight back into a param
|
|
109379
109435
|
ensureNoInitializer(p));
|
|
109380
109436
|
if (!suppressNewDiagnosticContexts) {
|
|
109381
109437
|
getSymbolAccessibilityDiagnostic = oldDiag;
|
|
@@ -117518,6 +117574,7 @@ var ts;
|
|
|
117518
117574
|
ts.Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code,
|
|
117519
117575
|
ts.Diagnostics.Class_constructor_may_not_be_a_generator.code,
|
|
117520
117576
|
ts.Diagnostics.Class_constructor_may_not_be_an_accessor.code,
|
|
117577
|
+
ts.Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code,
|
|
117521
117578
|
]);
|
|
117522
117579
|
/**
|
|
117523
117580
|
* Determine if source file needs to be re-created even if its text hasn't changed
|
|
@@ -122652,9 +122709,11 @@ var ts;
|
|
|
122652
122709
|
}
|
|
122653
122710
|
function watchAffectingLocationsOfResolution(resolution, addToResolutionsWithOnlyAffectingLocations) {
|
|
122654
122711
|
ts.Debug.assert(!!resolution.refCount);
|
|
122712
|
+
var affectingLocations = resolution.affectingLocations;
|
|
122713
|
+
if (!affectingLocations.length)
|
|
122714
|
+
return;
|
|
122655
122715
|
if (addToResolutionsWithOnlyAffectingLocations)
|
|
122656
122716
|
resolutionsWithOnlyAffectingLocations.push(resolution);
|
|
122657
|
-
var affectingLocations = resolution.affectingLocations;
|
|
122658
122717
|
// Watch package json
|
|
122659
122718
|
for (var _i = 0, affectingLocations_1 = affectingLocations; _i < affectingLocations_1.length; _i++) {
|
|
122660
122719
|
var affectingLocation = affectingLocations_1[_i];
|
|
@@ -170588,6 +170647,38 @@ var ts;
|
|
|
170588
170647
|
}
|
|
170589
170648
|
return result.module;
|
|
170590
170649
|
};
|
|
170650
|
+
/*@internal*/
|
|
170651
|
+
Project.importServicePluginAsync = function (moduleName, initialDir, host, log, logErrors) {
|
|
170652
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
170653
|
+
var resolvedPath, result, e_1, err;
|
|
170654
|
+
return __generator(this, function (_a) {
|
|
170655
|
+
switch (_a.label) {
|
|
170656
|
+
case 0:
|
|
170657
|
+
ts.Debug.assertIsDefined(host.importServicePlugin);
|
|
170658
|
+
resolvedPath = ts.combinePaths(initialDir, "node_modules");
|
|
170659
|
+
log("Dynamically importing " + moduleName + " from " + initialDir + " (resolved to " + resolvedPath + ")");
|
|
170660
|
+
_a.label = 1;
|
|
170661
|
+
case 1:
|
|
170662
|
+
_a.trys.push([1, 3, , 4]);
|
|
170663
|
+
return [4 /*yield*/, host.importServicePlugin(resolvedPath, moduleName)];
|
|
170664
|
+
case 2:
|
|
170665
|
+
result = _a.sent();
|
|
170666
|
+
return [3 /*break*/, 4];
|
|
170667
|
+
case 3:
|
|
170668
|
+
e_1 = _a.sent();
|
|
170669
|
+
result = { module: undefined, error: e_1 };
|
|
170670
|
+
return [3 /*break*/, 4];
|
|
170671
|
+
case 4:
|
|
170672
|
+
if (result.error) {
|
|
170673
|
+
err = result.error.stack || result.error.message || JSON.stringify(result.error);
|
|
170674
|
+
(logErrors || log)("Failed to dynamically import module '" + moduleName + "' from " + resolvedPath + ": " + err);
|
|
170675
|
+
return [2 /*return*/, undefined];
|
|
170676
|
+
}
|
|
170677
|
+
return [2 /*return*/, result.module];
|
|
170678
|
+
}
|
|
170679
|
+
});
|
|
170680
|
+
});
|
|
170681
|
+
};
|
|
170591
170682
|
Project.prototype.isKnownTypesPackageName = function (name) {
|
|
170592
170683
|
return this.typingsCache.isKnownTypesPackageName(name);
|
|
170593
170684
|
};
|
|
@@ -171648,7 +171739,7 @@ var ts;
|
|
|
171648
171739
|
};
|
|
171649
171740
|
Project.prototype.enableGlobalPlugins = function (options, pluginConfigOverrides) {
|
|
171650
171741
|
var host = this.projectService.host;
|
|
171651
|
-
if (!host.require) {
|
|
171742
|
+
if (!host.require && !host.importServicePlugin) {
|
|
171652
171743
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
171653
171744
|
return;
|
|
171654
171745
|
}
|
|
@@ -171677,21 +171768,66 @@ var ts;
|
|
|
171677
171768
|
}
|
|
171678
171769
|
}
|
|
171679
171770
|
};
|
|
171680
|
-
|
|
171771
|
+
/**
|
|
171772
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin synchronously using 'require'.
|
|
171773
|
+
*/
|
|
171774
|
+
/*@internal*/
|
|
171775
|
+
Project.prototype.beginEnablePluginSync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171681
171776
|
var _this = this;
|
|
171682
|
-
this.projectService.
|
|
171683
|
-
if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
|
|
171684
|
-
this.projectService.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
|
|
171685
|
-
return;
|
|
171686
|
-
}
|
|
171687
|
-
var log = function (message) { return _this.projectService.logger.info(message); };
|
|
171777
|
+
ts.Debug.assertIsDefined(this.projectService.host.require);
|
|
171688
171778
|
var errorLogs;
|
|
171779
|
+
var log = function (message) { return _this.projectService.logger.info(message); };
|
|
171689
171780
|
var logError = function (message) {
|
|
171690
|
-
(errorLogs
|
|
171781
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171691
171782
|
};
|
|
171692
171783
|
var resolvedModule = ts.firstDefined(searchPaths, function (searchPath) {
|
|
171693
171784
|
return Project.resolveModule(pluginConfigEntry.name, searchPath, _this.projectService.host, log, logError);
|
|
171694
171785
|
});
|
|
171786
|
+
return { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs };
|
|
171787
|
+
};
|
|
171788
|
+
/**
|
|
171789
|
+
* Performs the initial steps of enabling a plugin by finding and instantiating the module for a plugin asynchronously using dynamic `import`.
|
|
171790
|
+
*/
|
|
171791
|
+
/*@internal*/
|
|
171792
|
+
Project.prototype.beginEnablePluginAsync = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171793
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
171794
|
+
var errorLogs, log, logError, resolvedModule, _i, searchPaths_1, searchPath;
|
|
171795
|
+
var _this = this;
|
|
171796
|
+
return __generator(this, function (_a) {
|
|
171797
|
+
switch (_a.label) {
|
|
171798
|
+
case 0:
|
|
171799
|
+
ts.Debug.assertIsDefined(this.projectService.host.importServicePlugin);
|
|
171800
|
+
log = function (message) { return _this.projectService.logger.info(message); };
|
|
171801
|
+
logError = function (message) {
|
|
171802
|
+
(errorLogs !== null && errorLogs !== void 0 ? errorLogs : (errorLogs = [])).push(message);
|
|
171803
|
+
};
|
|
171804
|
+
_i = 0, searchPaths_1 = searchPaths;
|
|
171805
|
+
_a.label = 1;
|
|
171806
|
+
case 1:
|
|
171807
|
+
if (!(_i < searchPaths_1.length)) return [3 /*break*/, 4];
|
|
171808
|
+
searchPath = searchPaths_1[_i];
|
|
171809
|
+
return [4 /*yield*/, Project.importServicePluginAsync(pluginConfigEntry.name, searchPath, this.projectService.host, log, logError)];
|
|
171810
|
+
case 2:
|
|
171811
|
+
resolvedModule = (_a.sent());
|
|
171812
|
+
if (resolvedModule !== undefined) {
|
|
171813
|
+
return [3 /*break*/, 4];
|
|
171814
|
+
}
|
|
171815
|
+
_a.label = 3;
|
|
171816
|
+
case 3:
|
|
171817
|
+
_i++;
|
|
171818
|
+
return [3 /*break*/, 1];
|
|
171819
|
+
case 4: return [2 /*return*/, { pluginConfigEntry: pluginConfigEntry, pluginConfigOverrides: pluginConfigOverrides, resolvedModule: resolvedModule, errorLogs: errorLogs }];
|
|
171820
|
+
}
|
|
171821
|
+
});
|
|
171822
|
+
});
|
|
171823
|
+
};
|
|
171824
|
+
/**
|
|
171825
|
+
* Performs the remaining steps of enabling a plugin after its module has been instantiated.
|
|
171826
|
+
*/
|
|
171827
|
+
/*@internal*/
|
|
171828
|
+
Project.prototype.endEnablePlugin = function (_a) {
|
|
171829
|
+
var _this = this;
|
|
171830
|
+
var pluginConfigEntry = _a.pluginConfigEntry, pluginConfigOverrides = _a.pluginConfigOverrides, resolvedModule = _a.resolvedModule, errorLogs = _a.errorLogs;
|
|
171695
171831
|
if (resolvedModule) {
|
|
171696
171832
|
var configurationOverride = pluginConfigOverrides && pluginConfigOverrides.get(pluginConfigEntry.name);
|
|
171697
171833
|
if (configurationOverride) {
|
|
@@ -171703,10 +171839,13 @@ var ts;
|
|
|
171703
171839
|
this.enableProxy(resolvedModule, pluginConfigEntry);
|
|
171704
171840
|
}
|
|
171705
171841
|
else {
|
|
171706
|
-
ts.forEach(errorLogs,
|
|
171842
|
+
ts.forEach(errorLogs, function (message) { return _this.projectService.logger.info(message); });
|
|
171707
171843
|
this.projectService.logger.info("Couldn't find " + pluginConfigEntry.name);
|
|
171708
171844
|
}
|
|
171709
171845
|
};
|
|
171846
|
+
Project.prototype.enablePlugin = function (pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
171847
|
+
this.projectService.requestEnablePlugin(this, pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
171848
|
+
};
|
|
171710
171849
|
Project.prototype.enableProxy = function (pluginModuleFactory, configEntry) {
|
|
171711
171850
|
try {
|
|
171712
171851
|
if (typeof pluginModuleFactory !== "function") {
|
|
@@ -172358,7 +172497,7 @@ var ts;
|
|
|
172358
172497
|
/*@internal*/
|
|
172359
172498
|
ConfiguredProject.prototype.enablePluginsWithOptions = function (options, pluginConfigOverrides) {
|
|
172360
172499
|
var host = this.projectService.host;
|
|
172361
|
-
if (!host.require) {
|
|
172500
|
+
if (!host.require && !host.importServicePlugin) {
|
|
172362
172501
|
this.projectService.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
172363
172502
|
return;
|
|
172364
172503
|
}
|
|
@@ -172377,7 +172516,7 @@ var ts;
|
|
|
172377
172516
|
this.enablePlugin(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
172378
172517
|
}
|
|
172379
172518
|
}
|
|
172380
|
-
this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172519
|
+
return this.enableGlobalPlugins(options, pluginConfigOverrides);
|
|
172381
172520
|
};
|
|
172382
172521
|
/**
|
|
172383
172522
|
* Get the errors that dont have any file name associated
|
|
@@ -175799,6 +175938,147 @@ var ts;
|
|
|
175799
175938
|
}
|
|
175800
175939
|
return false;
|
|
175801
175940
|
};
|
|
175941
|
+
/*@internal*/
|
|
175942
|
+
ProjectService.prototype.requestEnablePlugin = function (project, pluginConfigEntry, searchPaths, pluginConfigOverrides) {
|
|
175943
|
+
var _a;
|
|
175944
|
+
if (!this.host.importServicePlugin && !this.host.require) {
|
|
175945
|
+
this.logger.info("Plugins were requested but not running in environment that supports 'require'. Nothing will be loaded");
|
|
175946
|
+
return;
|
|
175947
|
+
}
|
|
175948
|
+
this.logger.info("Enabling plugin " + pluginConfigEntry.name + " from candidate paths: " + searchPaths.join(","));
|
|
175949
|
+
if (!pluginConfigEntry.name || ts.parsePackageName(pluginConfigEntry.name).rest) {
|
|
175950
|
+
this.logger.info("Skipped loading plugin " + (pluginConfigEntry.name || JSON.stringify(pluginConfigEntry)) + " because only package name is allowed plugin name");
|
|
175951
|
+
return;
|
|
175952
|
+
}
|
|
175953
|
+
// If the host supports dynamic import, begin enabling the plugin asynchronously.
|
|
175954
|
+
if (this.host.importServicePlugin) {
|
|
175955
|
+
var importPromise = project.beginEnablePluginAsync(pluginConfigEntry, searchPaths, pluginConfigOverrides);
|
|
175956
|
+
(_a = this.pendingPluginEnablements) !== null && _a !== void 0 ? _a : (this.pendingPluginEnablements = new ts.Map());
|
|
175957
|
+
var promises = this.pendingPluginEnablements.get(project);
|
|
175958
|
+
if (!promises)
|
|
175959
|
+
this.pendingPluginEnablements.set(project, promises = []);
|
|
175960
|
+
promises.push(importPromise);
|
|
175961
|
+
return;
|
|
175962
|
+
}
|
|
175963
|
+
// Otherwise, load the plugin using `require`
|
|
175964
|
+
project.endEnablePlugin(project.beginEnablePluginSync(pluginConfigEntry, searchPaths, pluginConfigOverrides));
|
|
175965
|
+
};
|
|
175966
|
+
/* @internal */
|
|
175967
|
+
ProjectService.prototype.hasNewPluginEnablementRequests = function () {
|
|
175968
|
+
return !!this.pendingPluginEnablements;
|
|
175969
|
+
};
|
|
175970
|
+
/* @internal */
|
|
175971
|
+
ProjectService.prototype.hasPendingPluginEnablements = function () {
|
|
175972
|
+
return !!this.currentPluginEnablementPromise;
|
|
175973
|
+
};
|
|
175974
|
+
/**
|
|
175975
|
+
* Waits for any ongoing plugin enablement requests to complete.
|
|
175976
|
+
*/
|
|
175977
|
+
/* @internal */
|
|
175978
|
+
ProjectService.prototype.waitForPendingPlugins = function () {
|
|
175979
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
175980
|
+
return __generator(this, function (_a) {
|
|
175981
|
+
switch (_a.label) {
|
|
175982
|
+
case 0:
|
|
175983
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
175984
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
175985
|
+
case 1:
|
|
175986
|
+
_a.sent();
|
|
175987
|
+
return [3 /*break*/, 0];
|
|
175988
|
+
case 2: return [2 /*return*/];
|
|
175989
|
+
}
|
|
175990
|
+
});
|
|
175991
|
+
});
|
|
175992
|
+
};
|
|
175993
|
+
/**
|
|
175994
|
+
* Starts enabling any requested plugins without waiting for the result.
|
|
175995
|
+
*/
|
|
175996
|
+
/* @internal */
|
|
175997
|
+
ProjectService.prototype.enableRequestedPlugins = function () {
|
|
175998
|
+
if (this.pendingPluginEnablements) {
|
|
175999
|
+
void this.enableRequestedPluginsAsync();
|
|
176000
|
+
}
|
|
176001
|
+
};
|
|
176002
|
+
ProjectService.prototype.enableRequestedPluginsAsync = function () {
|
|
176003
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176004
|
+
var entries;
|
|
176005
|
+
return __generator(this, function (_a) {
|
|
176006
|
+
switch (_a.label) {
|
|
176007
|
+
case 0:
|
|
176008
|
+
if (!this.currentPluginEnablementPromise) return [3 /*break*/, 2];
|
|
176009
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
176010
|
+
return [4 /*yield*/, this.waitForPendingPlugins()];
|
|
176011
|
+
case 1:
|
|
176012
|
+
// If we're already enabling plugins, wait for any existing operations to complete
|
|
176013
|
+
_a.sent();
|
|
176014
|
+
_a.label = 2;
|
|
176015
|
+
case 2:
|
|
176016
|
+
// Skip if there are no new plugin enablement requests
|
|
176017
|
+
if (!this.pendingPluginEnablements) {
|
|
176018
|
+
return [2 /*return*/];
|
|
176019
|
+
}
|
|
176020
|
+
entries = ts.arrayFrom(this.pendingPluginEnablements.entries());
|
|
176021
|
+
this.pendingPluginEnablements = undefined;
|
|
176022
|
+
// Start processing the requests, keeping track of the promise for the operation so that
|
|
176023
|
+
// project consumers can potentially wait for the plugins to load.
|
|
176024
|
+
this.currentPluginEnablementPromise = this.enableRequestedPluginsWorker(entries);
|
|
176025
|
+
return [4 /*yield*/, this.currentPluginEnablementPromise];
|
|
176026
|
+
case 3:
|
|
176027
|
+
_a.sent();
|
|
176028
|
+
return [2 /*return*/];
|
|
176029
|
+
}
|
|
176030
|
+
});
|
|
176031
|
+
});
|
|
176032
|
+
};
|
|
176033
|
+
ProjectService.prototype.enableRequestedPluginsWorker = function (pendingPlugins) {
|
|
176034
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176035
|
+
var _this = this;
|
|
176036
|
+
return __generator(this, function (_a) {
|
|
176037
|
+
switch (_a.label) {
|
|
176038
|
+
case 0:
|
|
176039
|
+
// This should only be called from `enableRequestedPluginsAsync`, which ensures this precondition is met.
|
|
176040
|
+
ts.Debug.assert(this.currentPluginEnablementPromise === undefined);
|
|
176041
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
176042
|
+
// on a project with many plugins.
|
|
176043
|
+
return [4 /*yield*/, Promise.all(ts.map(pendingPlugins, function (_a) {
|
|
176044
|
+
var project = _a[0], promises = _a[1];
|
|
176045
|
+
return _this.enableRequestedPluginsForProjectAsync(project, promises);
|
|
176046
|
+
}))];
|
|
176047
|
+
case 1:
|
|
176048
|
+
// Process all pending plugins, partitioned by project. This way a project with few plugins doesn't need to wait
|
|
176049
|
+
// on a project with many plugins.
|
|
176050
|
+
_a.sent();
|
|
176051
|
+
// Clear the pending operation and notify the client that projects have been updated.
|
|
176052
|
+
this.currentPluginEnablementPromise = undefined;
|
|
176053
|
+
this.sendProjectsUpdatedInBackgroundEvent();
|
|
176054
|
+
return [2 /*return*/];
|
|
176055
|
+
}
|
|
176056
|
+
});
|
|
176057
|
+
});
|
|
176058
|
+
};
|
|
176059
|
+
ProjectService.prototype.enableRequestedPluginsForProjectAsync = function (project, promises) {
|
|
176060
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
176061
|
+
var results, _i, results_1, result;
|
|
176062
|
+
return __generator(this, function (_a) {
|
|
176063
|
+
switch (_a.label) {
|
|
176064
|
+
case 0: return [4 /*yield*/, Promise.all(promises)];
|
|
176065
|
+
case 1:
|
|
176066
|
+
results = _a.sent();
|
|
176067
|
+
if (project.isClosed()) {
|
|
176068
|
+
// project is not alive, so don't enable plugins.
|
|
176069
|
+
return [2 /*return*/];
|
|
176070
|
+
}
|
|
176071
|
+
for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
|
|
176072
|
+
result = results_1[_i];
|
|
176073
|
+
project.endEnablePlugin(result);
|
|
176074
|
+
}
|
|
176075
|
+
// Plugins may have modified external files, so mark the project as dirty.
|
|
176076
|
+
this.delayUpdateProjectGraph(project);
|
|
176077
|
+
return [2 /*return*/];
|
|
176078
|
+
}
|
|
176079
|
+
});
|
|
176080
|
+
});
|
|
176081
|
+
};
|
|
175802
176082
|
ProjectService.prototype.configurePlugin = function (args) {
|
|
175803
176083
|
// For any projects that already have the plugin loaded, configure the plugin
|
|
175804
176084
|
this.forEachEnabledProject(function (project) { return project.onPluginConfigurationChanged(args.pluginName, args.configuration); });
|
|
@@ -176627,7 +176907,6 @@ var ts;
|
|
|
176627
176907
|
server.CommandNames.OrganizeImportsFull,
|
|
176628
176908
|
server.CommandNames.GetEditsForFileRename,
|
|
176629
176909
|
server.CommandNames.GetEditsForFileRenameFull,
|
|
176630
|
-
server.CommandNames.ConfigurePlugin,
|
|
176631
176910
|
server.CommandNames.PrepareCallHierarchy,
|
|
176632
176911
|
server.CommandNames.ProvideCallHierarchyIncomingCalls,
|
|
176633
176912
|
server.CommandNames.ProvideCallHierarchyOutgoingCalls,
|
|
@@ -178895,7 +179174,9 @@ var ts;
|
|
|
178895
179174
|
Session.prototype.executeCommand = function (request) {
|
|
178896
179175
|
var handler = this.handlers.get(request.command);
|
|
178897
179176
|
if (handler) {
|
|
178898
|
-
|
|
179177
|
+
var response = this.executeWithRequestId(request.seq, function () { return handler(request); });
|
|
179178
|
+
this.projectService.enableRequestedPlugins();
|
|
179179
|
+
return response;
|
|
178899
179180
|
}
|
|
178900
179181
|
else {
|
|
178901
179182
|
this.logger.msg("Unrecognized JSON command:" + server.stringifyIndented(request), server.Msg.Err);
|