Add plugins property on TS Server open request
See original GitHub issueProblem
VSCode allows TSServer plugin extensions to register themselves for language modes besides javascript and typescript. The angular extension for example can register the angular TSServer plugin for the ng-html
language. When an ng-html
file is sent to TS and the angular plugin is not active, Typescript will treat the file contents as typescript code, resulting in a number of syntax errors
Proposal
Add an optional plugins
property on TSServer open
requests.
interface OpenRequestArgs {
...,
plugins?: string[]
}
plugins
would be a list of tsserver plugin package identifiers.
On the TypeScript side, the new logic for handling the plugins
property on open
requests would look something like:
- If
plugins
is undefined, theopen
request behaves the same as it does currently. - If
plugins
is an array, TypeScript checks to see if any of the plugins it has loaded are in theplugins
.- When no match is found, the opened file is ignored by the TSServer
- If a match is found, the opened file is handled by TypeScript. The plugin would be responsible for disabling the standard TS features in the file
Open Questions
What does ignoring a file mean?
What happens when plugins
is provided but no match is found against the loaded plugins on the TSServer? Two options I see:
-
TS keeps the file open and VSCode continues sending update events about it, but TS never actually generate any events or fufills any requests against it.
-
TS tells VSCode that it doesn’t care about this file, perhaps by returning an error from
open
VSCode would no longer send sync events about the file or send TS requests about it
scriptKindName
OpenRequestArgs
includes an optional field scriptKindName?: ScriptKindName
.
type ScriptKindName = "TS" | "JS" | "TSX" | "JSX";
Should a new kind for external files be added?
type ScriptKindName = "TS" | "JS" | "TSX" | "JSX" | "EXTERNAL";
Issue Analytics
- State:
- Created 6 years ago
- Reactions:8
- Comments:15 (10 by maintainers)
Top GitHub Comments
Just to mention, as @mjbvz recommended me to, it’s still a need for tools like Angular Language Service (see cyrilletuzi/vscode-typescript-angular-plugin#1).
@mjbvz I added a comment to https://github.com/Microsoft/vscode/commit/c2ee6133aa87d915f246e1ce1c33ef9b4f1b3888