Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between tsc (TypeScript compiler) and ts-node?

I'm very confused about the difference between tsc and ts-node. I'm learning TypeScript and I usually transpile server .ts files with tsc command.

Now, I'm approaching nestjs framework, and I see that it uses ts-node.

So what's the difference between the two? Which one should I use?

like image 321
gremo Avatar asked Jul 20 '18 18:07

gremo


People also ask

Does ts-node use TSC?

json (recommended)​ ts-node automatically finds and loads tsconfig. json . Most ts-node options can be specified in a "ts-node" object using their programmatic, camelCase names.

What is TSC in TypeScript?

The TypeScript Compiler (also known as "tsc") is the backbone of many bundlers, plugins, and tools that work with TypeScript. While we don't often invoke tsc directly, we do configure how tsc behaves inside of the bundlers that we use.

Should you use ts-node?

No you shouldn't use it in production, even though it will cache the compiled files it'll be slower to start and consume more memory because it keeps around an instance of the compiler and files in memory.

Does ts-node require TypeScript?

ts-node is a TypeScript execution engine and REPL for Node. js. It JIT transforms TypeScript into JavaScript, enabling you to directly execute TypeScript on Node. js without precompiling.


1 Answers

The main difference is that tsc transpile all the file according to your tsconfig. Instead, ts-node will start from the entry file and transpile the file step by step through the tree based on the import/export

like image 167
Adrien De Peretti Avatar answered Sep 28 '22 11:09

Adrien De Peretti