TypeScript's has a target
configuration with many values, like esnext
, es2015
, es6
etc. (very confusing)
NodeJs current version (11.11.0) supports many of the new features of JavaScript. Is it ok to target esnext
on TypeScript? will it work?
If not, what's the right target
to use when targeting nodeJs 11.11.0
Edit:
Thanks to @Seblor we know that esnext
is very dynamic and TC39 can add features as they see fit. It represents the next version of JavaScript that is being worked on (Regarding agreeing on features)
The refined question should be: According to the current version of NodeJs (11.11.0) and the current version of TypeScript (3.3) can we use esnext
as the target
?
TypeScript is well-established in the Node. js world and used by many companies, open-source projects, tools and frameworks. Some of the notable examples of open-source projects using TypeScript are: NestJS - robust and fully-featured framework that makes creating scalable and well-architected systems easy and pleasant.
"Npm", "Javascript" and "Great libraries" are the key factors why developers consider Node. js; whereas "More intuitive and type safe javascript", "Type safe" and "JavaScript superset" are the primary reasons why TypeScript is favored.
Node. js is primarily used for non-blocking, event-driven servers, due to its single-threaded nature. It's used for traditional web sites and back-end API services, but was designed with real-time, push-based architectures in mind.
Looking at node.green, ES2018 support seems to be full in Node 11.11.0, so you should be able to set ES2018 as target with no trouble.
You can push your luck by using ES2019 or even ESNext since the support looks good enough. However, I do not know if typescript will use non-yet-implemented features if you use ESNext as target (like the private properties).
Personally I would stick with ES2018, as I see no need to push for ESNext.
Based on Node-Target Mapping on the TypeScript wiki "es2018"
is the right mapping for Node 10, "es2019"
is the right mapping for Node 12. It seems that non-LTS versions of Node aren't documented, but given this information I feel like "es2018"
is the safest target.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With