不同 NodeJS 版本应使用哪个 tsc --target?
根据你打算支持的最低 NodeJS 版本,你应该为 tsc 使用以下 –target 设置:
- Node 10.x:
es2018 - Node 12.x:
es2019 - Node 14.x:
es2020 - Node 16.x:
es2021 - Node 17.x:
es2022 - Node 18.x:
es2022 - Node 19.x:
es2022 - Node 20.x:
es2022
注意,为 NodeJS 编译时,除了 --target 之外还有更多可能的配置。查看 Github 上的 tsconfig 基础配置示例 了解更多详情。
*来源:*Github 上的 tsconfig bases。
Check out similar posts by category:
NodeJS, Typescript
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow