GitXplorerGitXplorer
a

ts_plugin_prototype

public
9 stars
1 forks
0 issues

Commits

List of commits on branch master.
Unverified
75ef08ae8f6320d8005a9f0e53cd3779350bf452

fix tsc errors

aalexeagle committed 8 years ago
Unverified
1e88e569249e714af82637c7b10b850eb7c9999b

missing files

aalexeagle committed 8 years ago
Unverified
77f79e74a8f92e19c152038a1724cd2978e93610

Add example of emit transformer

aalexeagle committed 8 years ago
Unverified
e82ceea204a4f60281a4ce7f1fd8c1b4c1e751e2

Create README.md

aalexeagle committed 8 years ago
Unverified
f8c117a4fc3ed4acf19ee923dfee6d8c9280dbcd

Prototype of wiring a TS plugin into tsc

aalexeagle committed 8 years ago

README

The README file for this repository.

ts_plugin_prototype

Proof of concept for using TS 2.3 plugins and transformers in tsc_wrapped

There are three ways to extend TSC:

  1. Plugins that also work in an editor are written against the Language service using the plugin API introduced in https://github.com/Microsoft/TypeScript/pull/12231 These require a LanguageService wrapper around the program, and are expected to run in the tsserver.js editor helper, not in typescript.js This demo uses the @angular/language-service plugin as an example. Also see https://github.com/RyanCavanaugh/sample-ts-plugin for a simple example.
  2. Plugins written only for use with tsc can skip the LanguageService and just wrap the ts.Program. This example is in tscPlugin.ts.
  3. Emit transforms can mutate the AST before or after TypeScript lowers to the target language. See example in eraseDecoratorsTransform.ts.

This will let us re-write chunks of @angular/tsc-wrapped as plugins.

Demo

Here we see a diagnostic from TypeScript, a diagnostic from a plugin, and the decorator was removed by a before transform.

alexeagle@alexeagle:~/Projects/ts_plugin_prototype$ node built/runner.js
test_file.ts(1,14): error TS2322: Type '1' is not assignable to type 'string'.
test_file.ts(1,1): warning TS9999: Plugin diagnostic

alexeagle@alexeagle:~/Projects/ts_plugin_prototype$ cat built/test_file.js
"use strict";
exports.__esModule = true;
exports.a = 1;
function Cool(c) {
    return c;
}
var Foo = (function () {
    function Foo() {
    }
    return Foo;
}());