ts-node

A tool that executes a Node program that is written in TypeScript

Basically, instead of using this command every time:

1
tsc index.ts && node index.js

you can use this tool.

Installing and Usage

Install it globally by npm:

1
npm install -g ts-node

Create a file add.ts with simple TypeScript code:

1
2
3
4
5
function add(a: number, b: number): number {
  return a + b;
}

console.log(add(5, 5));

Run ts-node to execute this file:

1
ts-node add.ts

It will print the result:

1
10