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

问题描述 投票:0回答:2

这是我的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"
    ]
  }
}

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

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

请帮助我。

angular typescript ecmascript-next es2020
2个回答
3
投票

es2020 支持是 在TypeScript 3.8中引入.

你必须升级到 Angular 9.1 使用TypeScript 3.8。


1
投票

我不认为 es2020 被添加为目标,直到Angular 9。所以如果你的版本低于这个版本,我可以看到它无法工作。

esnext 目标是最新支持的特性,所以工作起来应该非常相似。

© www.soinside.com 2019 - 2024. All rights reserved.