Quick setup
- Download and install Node.js.
- Open the terminal and install TypeScript globally:
npm install -g typescript - Create a JavaScript file and add some content; let’s call it
index.ts:console.log("Hello world!"); - Transpile your file into a JavaScript file:
tsc index.ts - Verify that a
index.jsfile was created at the side of theindex.tsfile. - Run your new JavaScript file with Node:
node index.js
Bonus
You can use the tsc index.ts --watch command to continuously monitor your TypeScript file for changes and transpile it to JavaScript every time your .ts file is saved.