【发布时间】:2017-01-30 06:21:59
【问题描述】:
我正在学习 Angular2 教程,并且一直在阅读每个部分,直到我打开 tsconfig.json 并停在以下位置:"target": "es5"。这意味着我编译为 ECMAScript 5。
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
}
}
我目前正在使用 ES5。我应该将目标更改为"es6" 还是"es7"?使用更高版本有什么好处?
【问题讨论】:
-
谁是“我们”?大多数当前浏览器仅原生支持 ES5,因此这是目前最常见的设置。
-
ES 还没有被所有浏览器支持kangax.github.io/compat-table/es6,es7 还很遥远。只有在 Node.JS 中使用 Typescript,而不是浏览器应用,才能转码为 es6
-
感谢您的澄清!我不确定要坚持哪个版本,但我现在会继续使用 ES5。
-
@jonrsharpe 这不是真的。最新版本的 Edge、Firefox 和 Chrome 支持超过 90% 的 ES 6。只有在必须支持 IE 时才需要编译到 ES 5。
标签: typescript ecmascript-6 ecmascript-5 ecmascript-2016 tsconfig