Closure Compiler + Typescript

I want to use Typescript and then Closure Compile (Advanced Compilation) to target ES5 and minimize output.

Do i need to use tsickle instead of tsc? It does not have support for all tsc variants, and has far-reaching ambitions in the sense that it wants to translate Typescript types of type Closure (which are not 100% compatible). I do not need to use Closure types; I just need to rename the rights / properties.

Can I use tsc to compile Typescript modules in ES6 and use the Closure Compiler to minimize them (without type checking or type optimization)?

Bonus: does this answer change if I want to use the Closure Library?

+6
source share
1 answer

Technically, you can pull ES6 out tscand immediately pass it to the Closure Compiler, since the latter should accept JS as input. We already do this in many places, for example. Angular applications compiled with a closure compiler take the rxjs library distribution kit and include it in the closure kit. See https://github.com/angular/closure-demo

In practice, we find several reasons to use something like tsickle to transform JS before Closure sees it.

  • enums emit does not work in Closure (or rollup IIUC)
  • Closure has some limitations with ES6, for example, it does not currently support it export *- tsickle rewrites that onexport {each, visible, symbol}
  • JSDoc , , .

, tsickle TS 2.3 emit transforms, , .

. , {?} . , - TypeScript JS, , .

, - tcickle toolchain Bazel https://github.com/bazelbuild/rules_typescript. Tsickle main . ( , Lucidchart ?)

+5

All Articles