Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what version of javascript does typescript compile to?

I am a typescript noob and javascript dummy so please be as explicit as possible without being too nerdy.

My basic understanding is Typescript gets precompiled into Javascript by a mystical being. The Javascript is then rendered by the browser. However, if that javascript is too advanced for the browser, you can use babel to stupify the javascript code into yet another Javascript version, like ES5 (which I heard Internet Explorer can now handle as of a couple weeks ago).

So question: What Javascript version does Typescript compile into? (ES6, ES5, etc?) How can I modify this as needed?

like image 641
thedanotto Avatar asked Jan 07 '16 01:01

thedanotto


1 Answers

You can specify the target ECMAScript version with the --target option.


Here is how you do it in Visual Studio.

... change TypeScriptTarget in the .csproj file ...

<TypeScriptTarget>ES5</TypeScriptTarget>


Here is how you do it from the command line. (notice that ES3 is the default)

+----------+-----------+---------------------------------------------+
| Option   | Shorthand |               Description                   |
+----------+-----------+---------------------------------------------+
| --target |    -t     | Specify ECMAScript target version: 'ES3'    |
|          |           | (default), 'ES5', or 'ES6'                  |
+----------+-----------+---------------------------------------------+
like image 56
Frank Bryce Avatar answered Oct 08 '22 07:10

Frank Bryce