angular - 如果您不关心旧浏览器,将 tsconfig 目标设置为 es6 是否安全?

标签 angular typescript ecmascript-6 es6-class angular-library

在 Angular 应用程序中,将 tsconfig.json compilerOptions.target 设置为 "es6"(或等效的 "es2015") 如果你不关心旧浏览器?

关于这件事,在official Angular documentation写成:

By default, the target is es5, you can configure the target to es6 if you only want to deploy the application to es6 compatible browser. But if you configure the target to es6 in some old browser such as IE, Syntax Error will be thrown.

所以假设我确实只想将我的应用程序部署到兼容 es6 的浏览器,我是否应该将编译目标设置为 es6

还有其他我应该注意的问题吗?

例如,一些 Angular 第三方库开始不工作并抛出臭名昭著的错误:

TypeError: Class constructors cannot be invoked without 'new'

假设在这些情况下此类第三方库中存在错误是否正确?

最佳答案

是的,你绝对可以在你的 tsconfig.json 中使用 es6 目前我在过去 10 个月的应用程序中使用 esnext 因为我只针对谷歌浏览器,我没有发现任何由此产生的问题

谢谢!快乐编码

关于angular - 如果您不关心旧浏览器,将 tsconfig 目标设置为 es6 是否安全?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53339089/

相关文章:

html - *ngFor 在 IONIC 2 中有两种方式绑定(bind)

angular - Ag-Grid 没有以 Angular 2 显示?

typescript - 无法在 typescript 版本 3.1.6 中使用 BigInt。错误 TS2304 : Cannot find name 'BigInt'

javascript - 时间死区 - 默认参数 ReferenceError

javascript - ES6 模块拼接

angular - 如何避免在重新加载时使用参数解码 url

angular - 使用 forRoot 传递配置数据

Typescript const 枚举问题

css - ionic 2 : Beta 8 - scrollable content area cutting off button at bottom

javascript - 从另一个模块导出模块类