Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How should i use ES2020 in Angular?

Here is my tsconfig.json file:

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es6",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

When I changed lib and target version to es2020 it gives me below error:

tsconfig.json(13,15): error TS6046: Argument for '--target' option must be: 'es3', 'es5', 'es6', 'es2015', 'es2016', 'es2017', 'es2018', 'esnext'.

like image 261
Swanand Avatar asked May 04 '20 12:05

Swanand


2 Answers

es2020 support was introduced in TypeScript 3.8.

You must upgrade to Angular 9.1 (or later) to use TypeScript 3.8.

like image 114
JSON Derulo Avatar answered Sep 22 '22 08:09

JSON Derulo


I don't think es2020 was added as a target until Angular 9. So if you're on a version lower than that, I could see it not working.

esnext targets the latest supported features, so that should work very similarly.

like image 41
Jesse Avatar answered Sep 21 '22 08:09

Jesse