The upcoming TypeScript 1.4 exposes a
compiler API. One thing it can be used for is formatting your TypeScript code. Here is a complete example that formats a very simple class. The language service finds two changes in spacing. The changes are then applied and the resulting formatted class is printed.
app.ts