The compiler option for my angularjs application is as below. Should I use any other package to transpile es6 to es5 again if I change the target to es6?
{
"compilerOptions": {
"target": "es5", // Change this to es6
"module": "commonjs",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"outDir": "./wwwroot/app/"
},
"exclude": [
"node_modules",
"wwwroot"
]
}
Which target you pick is dependent on which browsers you support. Looking at the The ES6 Compatibility Table, we can make general guidelines about what to target. As long as the platform support is greater than or equal to TypeScript support, then we can estimate what we want to target:
target: ES3 - If you want to support:
target: ES5 - If you want to support:
target: ES6 (ES2015) - If you use these features and you want to support:
target: ES7 (ES2016) - If you use these features and you want to support:
target: ES2017 - If you use these features and you want to support:
target ES2018 - If you use these features and you want to support:
target ES2019 - If you use these features and you want to support:
target ES2020 - Which leaves us with the browsers than handle everything as of this post:
Hopefully this will give you an idea of what to target, but testing is essential to guarantee you support the platforms you want. There might be smaller features not in the compatibility table or something I missed, so be sure to test.
Targeting ES5 is currently a baseline requirement
*According to The ES6 Compatibility Table:
class
isn't supported in
Note: This is just for the latest. Many of the ES6 features that would provide a measurable benefit have only been implemented in the latest browser versions. Ie backward-compatibility is virtually nonexistent.
There are likely other use cases that would be better described using ES6 that aren't fully supported by browser.
In short, you should target ES5 for the foreseeable future until browsers have a chance to catch up.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With