- we will use Node.js to install and configure the development environment;
- install TypeScript using Node Package Manager (npm), which is automatically installed with Node.js:
npm install -g typescript. This command installs TypeScript globally on your computer, allowing you to use it in any project; - after installation, you can check the TypeScript version and its functionality using:
tsc -v; - to work with TypeScript, I recommend using Visual Studio Code (VS Code).
Now we have everything we need to get started with TypeScript! You can create a new TypeScript file with the .ts extension and start writing code.
test.ts
function add(num1: number, num2: number) {
return num1 + num2;
}
add(1, 1);Let's compile it in the console using the command:
tsc test.ts.
We have a js file next to the ts file:
Let's open the js file:
the contents of our ts file were overwritten by our js format.
We can also monitor file changes in real time by running the command:
tsc test.ts -w or tsc test.ts -watch.
In order not to stop npm start execution every time, you can open tsc -w in a separate console.
Every time you save the file, it will be recompiled, if there is an error, you will immediately see it in the console.
This repository was created and maintained by Oleksii Shevchenko. Questions, suggestions and feedback can be directed to email or linkedin profile. If you have any questions or suggestions, feel free to create an issue or submit a pull request.

