TypeScript: What's the "right" `target` for node 11?

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.


Ok so the answer is (As usual) Depends! It depends on the features that you plan on using. The TypeScript version, target on the tsconfig.json and the NodeJS version.

There are two things to check before you can use a JavaScript feature:

  1. You have to look at this table, and look at your target environment column, in my case it's NodeJs column. And make sure that the cell is Green. Red means that you can't run this feature on this environment.

  2. Make sure that you can compile your code using TypeScript. If you can compile the code using TypeScript, you're ok. Note that you can NOT count on the TypeScript column. Red cell means that the compiled code will not run on previous version of JavaScript...

For example BigInt:

TypeScript with target: "esnext" will compile (With no problem) a code with bigint (While the support cell is Red), and you can run a JavaScript code with bigint on NodeJS 11

Note that on the top left, there's the ECMAScript version-group. you can go lower than esnext