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

Is it safe to set the tsconfig target to es6 if you don't care about old browsers?

在 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 的浏览器 ONLY,我应该将编译目标设置为es6

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

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

TypeError: Class constructors cannot be invoked without 'new'

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

是的,你绝对可以在你的 tsconfig.json 中使用 es6 目前我在过去 10 个月的申请中使用 esnext 因为我只针对 google chrome ,我没有发现任何因此而产生的问题

谢谢!快乐编码