Skip to content

Commit 6b89247

Browse files
committed
Allow extension contributed TS plugins to be loaded for workspace versions of TS
Fixes microsoft#65031 Adds a `enableForWorkspaceTypeScriptVersions` flag (default false) to the plugins contributions that allows a contributed plugin to be loaded for workspace versions of ts
1 parent 3a0be84 commit 6b89247

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

extensions/typescript-language-features/schemas/package.schema.json

+5
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@
1616
"name": {
1717
"type": "string",
1818
"description": "Name of the plugin as listed in the package.json."
19+
},
20+
"enableForWorkspaceTypeScriptVersions": {
21+
"type": "boolean",
22+
"default": false,
23+
"description": "Should the plugin be loaded when using workspace versions of TypeScript?"
1924
}
2025
}
2126
}

extensions/typescript-language-features/src/tsServer/server.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,11 @@ export class TypeScriptServerSpawner {
113113
if (pluginManager.plugins.length) {
114114
args.push('--globalPlugins', pluginManager.plugins.map(x => x.name).join(','));
115115

116-
if (currentVersion.path === this._versionProvider.defaultVersion.path) {
117-
pluginPaths.push(...pluginManager.plugins.map(x => x.path));
116+
const isUsingBundledTypeScriptVersion = currentVersion.path === this._versionProvider.defaultVersion.path;
117+
for (const plugin of pluginManager.plugins) {
118+
if (isUsingBundledTypeScriptVersion || plugin.enableForWorkspaceTypeScriptVersions) {
119+
pluginPaths.push(plugin.path);
120+
}
118121
}
119122
}
120123

extensions/typescript-language-features/src/utils/plugins.ts

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { memoize } from './memoize';
1010
export interface TypeScriptServerPlugin {
1111
readonly path: string;
1212
readonly name: string;
13+
readonly enableForWorkspaceTypeScriptVersions: boolean;
1314
readonly languages: ReadonlyArray<string>;
1415
}
1516

@@ -25,6 +26,7 @@ export class PluginManager extends Disposable {
2526
for (const plugin of pack.contributes.typescriptServerPlugins) {
2627
plugins.push({
2728
name: plugin.name,
29+
enableForWorkspaceTypeScriptVersions: !!plugin.enableForWorkspaceTypeScriptVersions,
2830
path: extension.extensionPath,
2931
languages: Array.isArray(plugin.languages) ? plugin.languages : [],
3032
});

0 commit comments

Comments
 (0)