Search code examples
typescriptecmascript-6ecmascript-5ecmascript-2016tsconfig

What's the recommended version of ECMAScript that my TypeScript should compile to?


I'm working through Angular2 tutorials, and I've been going through each section until I opened the tsconfig.json and stopped at the following: "target": "es5". This means that I compile to ECMAScript 5.

{    
   "compilerOptions": {    
     "target": "es5",
     "module": "commonjs",
     "moduleResolution": "node",
     "sourceMap": true,
     "emitDecoratorMetadata": true,
     "experimentalDecorators": true,
     "removeComments": false,
     "noImplicitAny": false
   } 
 }

I'm currently using ES5. Should I change the target to "es6" or "es7"? What's the advantage of using later versions?


Solution

  • It mostly depends on the browsers you're supporting.

    If you need to support IE, old safari or mobile browsers, go with es5,

    if you need to support only latest chrome and firefox or edge and Safari 10, you probably can go with es6.

    But I'd suggest you go with es5 for now.