Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I transpile TypeScript to ES6?

Basically I need to be able to write TypeScript code in my IDE (this introduces great ease to development), compile it to ES6 and then apply babel.js (as all browsers doesn't support most ES6) to get the resulting ES5 scripts.

Is this possible? How can I achieve this?

like image 551
zmii Avatar asked May 25 '15 13:05

zmii


People also ask

Does TypeScript transpile to JavaScript?

Install the TypeScript compiler#You will need to install the TypeScript compiler either globally or in your workspace to transpile TypeScript source code to JavaScript ( tsc HelloWorld. ts ). You can test your install by checking the version or help.

What does TypeScript transpile to?

Typescript does transpile into Javascript. In your tsconfig configuration file, you can specify which is the target language you want it transpiled to. That means you can already work with cutting edge ECMAScript features out of the box.

How is TypeScript converted to JavaScript?

TypeScript Code is converted into Plain JavaScript Code: TypeScript code can't be natively interpreted by browsers. So if the code was written in TypeScript, it gets compiled and converted into JavaScript. This process is known as Trans-piled.


1 Answers

Yes.

You can target TypeScript compiler to ES6.

For example add this to your command line args:

--target es6 
like image 131
Sahar Menashe Avatar answered Sep 20 '22 06:09

Sahar Menashe