tsserver-plugins
v0.2.0
Published
Load 'Language Service Plugins' with TypeScript version which doesn't support 'Language Service Plugins'
Downloads
48
Readme
tsserver-plugins
Language Service Plugins with Proxies
Language Service Plugins with Proxies is planned for TypeScript 2.3. This feature gives the capability to extend TypeScript tsserver completion, definition, diagnostics, etc with custom plugins. Today it exists 2 plugins :
- Angular2 language service which provide completion, definition, diagnostics for @Component/template
- tslint language service which provides diagnostics, codefix by consuming tslint.
When a TypeScript file must be validated by tslint, the tslint language service plugin uses the parsed TypeScript file from tsserver and avoid double parsing of TypeScript file (one by tsserver and one by tslint).
Current work can be found in this PR
What is the goal of tsserver-plugins?
Language Service Plugins with Proxies will be available for for TypeScript 2.3. For the impatient guys,
tsserver-plugins gives you the capability to consume plugins with old version of TypeScript. Instead of starting tsserver with the bin/tsserver command, you start your tsserver with bin/tsserver-plugins which overrides the ts.createLanguageService
function to load plugins declared in your tsconfig.json like this:
{
"compilerOptions": {
"plugins": [
{ "name": "tslint-language-service"},
{ "name": "@angular/language-service"}
]
}
}
the bin/tsserver-plugins concat the src/before-tsserver.js which load the declared plugins from tsconfig.json
with the given lib/tsserver.js file of your TypeScript node_modules
.
How to use it?
- install tsserver-plugins:
npm install tsserver-plugins
Your node_modules
should look like after installing TypeScript and some language service plugins:
- node_modules
- @angular
- language-service
- tslint-language-service
- tsserver-plugins
- bin
- tsserver-plugins
- bin
- typescript
- bin
- tsserver
- bin
- @angular
Declare plugins in your tsconfig.json:
{
"compilerOptions": {
"plugins": [
{ "name": "tslint-language-service"},
{ "name": "@angular/language-service"}
]
}
}
Start tsserver with tsserver-plugins/bin/tsserver-plugins
instead of starting with typescript/bin/tsserver
. After that you will benefit with plugins language service. Here a sample with Angular2 and tslint language service: