Ad

What Version Of Javascript Does Typescript Compile To?

- 1 answer

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?

Ad

Answer

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'                  |
+----------+-----------+---------------------------------------------+
Ad
source: stackoverflow.com
Ad