How to write a Typescript plugin?

You can download https://github.com/microsoft/typescript or via npm.

npm install typescript

Then include it into your project and via Compiler API or TypeScript Language Service work with TypeScripts codes. You can write your own compiler if you need. Basics are described on the wiki.

https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API

https://github.com/Microsoft/TypeScript/wiki/Using-the-Language-Service-API


There are now some docs available for language service plugins at:

https://github.com/microsoft/TypeScript/wiki/Writing-a-Language-Service-Plugin

But note that the language service is not called by the tsc command, but only from apps (typically IDEs / editors I believe).

The https://github.com/cevek/ttypescript project patches tsc to support transformers which may be a route for people who require support in the tsc command too.