我正在开发一个 TypeScript 项目,我们使用 ES2017 作为输出目标以及其中一个库,因为它将通过 Babel,我们希望支持任何“Env”的最新功能集我们的目标是 Babel。
一切似乎都很好,所以我不太担心。但是,我不知道幕后发生了什么或“lib”选项真正做了什么(除了告诉我的 IDE 我可以做什么,比如传播操作、承诺等),以及是否更多/指定 TypeScript 的最高输出然后编译到 Babel 中非常特定的目标效率较低。这也是通过 WebPack 进行的,所以我们正在利用 tree shaking 的优势。
第二个问题是,当库中包含“ES2017”时,是否包含 ES2015 和 ES2016 中的所有功能(换句话说,是否有任何理由将 ES2015 和/或 ES2016 包含在列表中?)
{
"compilerOptions": {
"target": "ES2017",
"module": "ES2015",
"moduleResolution": "Node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"noEmitHelpers": true,
"importHelpers": true,
"pretty": true,
"alwaysStrict": true,
"lib": [
"DOM",
"ES2017",
"DOM.Iterable",
"ScriptHost"
],
"baseUrl": "./client",
"paths": {
"styles/*": ["./app/styles/*"],
"core/*": ["./app/core/*"],
"components/*": ["./app/components/*"],
"containers/*": ["./app/containers/*"],
"assets/*": ["./assets/*"],
"config/*": ["./config/*"]
}
},
"files": [
"./client/custom-typings.d.ts",
"./client/app/app.ts"
]
}
顺便说一句,在 Babel "Env" 中定位 "last 1 Chrome version" 时,它几乎不做任何转译,这非常令人兴奋。我们只是在构建原型,而不是生产代码,所以当我们需要支持它们时,我们会专门添加我们需要支持的浏览器,但几乎从不做任何不是 Chrome 的最后 1 或 2 个版本的事情。