mizech mizech - 4 months ago 24
TypeScript Question

Are ES6 features compiled to ES5 when used within TypeScript?

When I use ES6 features like for example template string, arrow functions, destructuring within a TypeScript file. Afterward I compile the file to normal JavaScript ...

Are the ES6 syntax compiled too by the TypeScript compiler? Or do I have to use an additional compiler (Babel)?


You need additional compilers that downport your code from ES6 to ES5.

TypeScript is pretty smart and will do most of the work for you (i.e. translate let to var or arrow functions to standard functions with right scope and bindings).

It sometimes fails though. For instance if your code requires Promises it won't compile until you set the ES6 target.