2

As Typescript is a global npm module, is there any relation between the typescript version and the node version ?

ie, do I need any minimum version of node required for any specific version of typescript to run.

Akash Dathan
  • 4,348
  • 2
  • 24
  • 45

1 Answers1

5

TypeScript is a compiler (or some call it a transpiler). It compiles your TypeScript into regular Javascript that node.js can then run. You can specify options for TypeScript to tell it what level of Javascript you are targeting. See the --target option here for details.

So, it is up to you to match the compiler target options with the appropriate version of node.js that you're running the code in. For example, if you're running node.js v9, you can target ES6 or perhaps even ES2016 or ES2017. If you were using node.js v3, you might target ES5. This determines what level of Javascript capabilities the TypeScript compiler assumes are present in the host environment.

You can see more about what Typescript options to set for which versions of node.js in this reference:

recommended typescript config for node 8

jfriend00
  • 683,504
  • 96
  • 985
  • 979
  • But @types/node created for different versions of node support only part of ts versions. dist-tags: latest: 20.2.4 ...ts3.8: 17.0.21... ts4.2: 18.15.3 ts4.3: 20.2.4 – Crusader May 26 '23 at 15:33