I want to use ES6 code (such as collections) in an Angular 4+ project built with angular-cli. Here is the tslint.json I'm using:
{
"compilerOptions": {
"baseUrl": "",
"declaration": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"lib": ["dom","es2017"],
"mapRoot": "./",
"module": "es6",
"moduleResolution": "node",
"outDir": "../dist/out-tsc",
"sourceMap": true,
"target": "es6",
"typeRoots": [
"../node_modules/@types"
]
}
}
Note that target has to be es6, since Typescript can't transpile ES6 code to ES5.
Unfortunately, angular-cli uses webpack2 which seems to have a hardwired dependency on UglifyJS which is incompatible with ES6 and it is unlikely this will be fixed anytime soon. I could choose not to use ES6 code or angular-cli, but before I give up on either, I'm wondering if there's a reasonable workaround for this issue?