I'm working on a TypeScript project and we're using ES2017 as the output target, as well as one of the libs, because it'll then go through Babel, and we want to support the latest feature set for whatever "Env" we're targeting in Babel.
Everything seems to work fine, so I'm not too worried about it. However, I don't know what's going on behind the scenes or what the "lib" option really does (other than tell my IDE what things I can do, like spread ops, Promises, etc.), and if it is more/less efficient to specify the highest output from TypeScript to then be compiled to a very specific target in Babel. This is going through WebPack, too, so we're taking advantage of tree shaking.
Second question is, when "ES2017" is included in the lib, does that include all features in ES2015 and ES2016 (in other words, is there any reason to include ES2015 and/or ES2016, with ES2017 in the list?)
{
"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"
]
}
As an aside, when targetting "last 1 Chrome version" in Babel "Env", it hardly does any transpiling at all, which is pretty exciting. We're just building prototypes, not production code, so we specifically add browsers we need to support when we need to support them, but almost never do anything that isn't the last 1 or 2 versions of Chrome.