我应该如何在 Angular 中使用 ES2020?

Swa*_*and 3 typescript ecmascript-next angular ecmascript-2020

这是我的 tsconfig.json 文件:

{
  "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"
    ]
  }
}
Run Code Online (Sandbox Code Playgroud)

当我将 lib 和目标版本更改为 es2020 时,它给了我以下错误:

tsconfig.json(13,15):错误 TS6046:“--target”选项的参数必须是:“es3”、“es5”、“es6”、“es2015”、“es2016”、“es2017”、“es2018” ,'esnext'。

JSO*_*ulo 11

es2020在 TypeScript 3.8引入了支持。

您必须升级到Angular 9.1(或更高版本)才能使用 TypeScript 3.8。