出于性能目的,兼容性和可伸缩性,这是编译器TypeScript在NodeJS模块中使用的最佳ECMAScript target?
根据NodeJS ES6 (ECMAScript 2015)不完全支持。是否值得使用ES6或者更好的兼容性来添加目标ES5与Typescript自动生成的相关变通方法?
另一方面,此时这些是NodeJS for ES6中正在进行的功能:
--harmony-do-expressions (enable "harmony do-expressions" (in progress))
--harmony-class-fields (enable "harmony fields in class literals" (in progress))
--harmony-static-fields (enable "harmony static fields in class literals" (in progress))
--harmony-array-flatten (enable "harmony Array.prototype.flat{ten,Map}" (in progress))
--harmony-locale (enable "Intl.Locale" (in progress))
我不知道此时是否需要这些功能,但是为了代码的可维护性,它可能不是最好的选择。
Node.js fully supports ECMAScript 2015,tail call optimization和ES modules除外(实验支持有标志和.mjs扩展名)。
在Node中使用TypeScript转换到ES5是没有意义的,TypeScript不严格遵循规范,也可能有其局限性,特别是the extension of native ES6 classes。