Open In App

How to execute TypeScript file using command line?

TypeScript is an open-source programming language. It is developed and maintained by Microsoft. TypeScript follows JavaScript syntactically but adds more features to it. It is a superset of JavaScript. In order to execute or run any typescript file, first you need to install node and using it install typescript globally in your local system.



After installing typescript, create a .ts file, for example, greet.ts as given below:



Procedure 1: This typescript file greet.ts will create a javascript file at runtime with the same name. To run any typescript file there are a few ways:
Syntax:

Procedure 2: You can merge both the commands by using a pole | and && like below :
Syntax:

Procedure 3: You can also install ts-node along with typescript using the following command:

Syntax:

Output: Using any of the three ways, the output will remain the same.

Greetings from GeeksforGeeks
Article Tags :