Home

Awesome

tsserver-plugins

NPM version

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 :

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?

npm install tsserver-plugins

Your node_modules should look like after installing TypeScript and some language service plugins:

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:

Language service demo