This project is read-only.

TypeScript compiler's formatting of arrays

Topics: General
Apr 1, 2013 at 7:46 AM
Is there a way to make the TypeScript compiler retain the original formatting (like in the TypeScript source files it compiled) of an array in the JavaScript files it outputs?

I wrote a simple implementation of Conway's Game of Life using the canvas element ( and I copied a "Gosper Glider Gun" pattern into a 40 by 40 multi-dimensional array and the compiler took 200 lines of typescript and turned it into 1800 lines of JavaScript (one element of the multi-dimensional array per line).
Apr 1, 2013 at 3:31 PM
I believe the Typescript team is working on preserving whitespace (and non-whitespace). It likely won't be out very soon though, as it's probably not at the top of their priority list. Your best bet is to get a Javascript formatter that you like and apply that to the generated code. If you're using Visual Studio (or another decent IDE), you can make the IDE automatically run the formatter as a post-build event.