user8261439
user8261439

Reputation:

Minify and optimize Typescript code using type information?

I'm preparing for the js13k game dev competition and have been searching for ways to minify TypeScript code. Base on this SO question from 4 years ago, the solution seems to be compiling TypeScript code to JS and use the regular js tools but in doing so you lose all the valuable type information.

Is there any way to make use of TypeScript's types to better minify and optimize the code's output?

Upvotes: 5

Views: 3500

Answers (1)

apokaliptis
apokaliptis

Reputation: 479

I know this question is two years old, but I ran across this question looking for something similar and this is what I've found so far (note that the latter two, at time of writing, both are works in progress):

  1. typescript-plus: a TypeScript compiler that includes some additional compiler features, including some optimizations.
  2. ts-optimizer: a proof-of-concept TypeScript optimizer.
  3. Tsickle + Closure Compiler: Tsickle is a code transpiler from Google that converts TypeScript code into JavaScript code that is acceptable to Google's Closure Compiler. Closure compiler then analyzes your code and strips unused portions then optimizes and minifies the rest. The Closure Compiler is capable of leveraging type information via its own variation of JSDoc annotations.

Upvotes: 2

Related Questions