Which tsc –target to use for different NodeJS versions?

Depending on the minimum NodeJS version you intend to support,, you should use the following –target settings for tsc:

  • Node 10.x: es2018
  • Node 12.x: es2019
  • Node 14.x: es2020
  • Node 16.x: es2021
  • Node 17.x: es2022
  • Node 18.x: es2022
  • Node 19.x: es2022
  • Node 20.x: es2022

Note that there are more configurations possible than just --target when compiling for NodeJS. See the tsconfig base config examples on Github for more details.

Source: The tsconfig bases on Github.