Which target you pick is dependent on which browsers you support. Looking at the The ES6 Compatibility Table, we can make general guidelines about what to target. As long as the platform support is greater than or equal to TypeScript support, then we can estimate what we want to target:
target: ES3 - If you want to support:
target: ES5 - If you want to support:
- IE11
- (iOS) Safari 9
- Opera Mini
- Android Browser
- Potentially Firefox ESR or Edge 14. They implement some/most of ES6, but there may be a few features missing. Check if you need said features or can polyfill/shim them.
target: ES6 (ES2015) - If you use these features and you want to support:
target: ES7 (ES2016) - If you use these features and you want to support:
target: ES2017 - If you use these features and you want to support:
target ES2018 - If you use these features and you want to support:
- Basically anything ES2019+: Edge 18, Samsung 8, Safari 12.0/iOS 11.3
- Object.fromEntries: Chrome 72, iOS 12.0, Samsung 10, Opera Mobile 51
- Array.prototype[@@unscopables].flat/flatMap: Firefox 66, Chrome 72, Safari 12.1/iOS 12.2, Samsung 10, Opera Mobile 51
- Symbol.prototype.description: Samsung 9
- JSON.stringify UTF surrogate pairs: iOS 12.0, Samsung 10
target ES2019 - If you use these features and you want to support:
- Basically anything ES2020+: Samsung 10, Safari 12.1/iOS 12.2, Opera Mobile 51
- String.prototype.matchAll: Firefox 66, Chrome 72
- Promise.allSettled: Firefox 71, Chrome 76
- optional chaining operator (?.): Firefox 74, Chrome 80, Safari 13/iOS 13, Opera Mobile 55
- nullish coalescing operator (??): Firefox 72, Chrome 80, Safari 13/iOS 13, Opera Mobile 55
target ES2020 - Which leaves us with the browsers than handle everything as of this post:
- Firefox 74+
- Chrome 80+ (include it's Edgium 80+ and Operium 67+ rebrands)
- Safari 13.1
Hopefully this will give you an idea of what to target, but testing is essential to guarantee you support the platforms you want. There might be smaller features not in the compatibility table or something I missed, so be sure to test.