TypeScript is a programming language that builds on top of JavaScript. Code written in TypeScript is converted to JavaScript. Then you can run JavaScript code in a browser, on Node.js runtime environment or something else where JavaScript is supported. TypeScript adds additional features for JavaScript.
This tutorial shows how to install TypeScript on Ubuntu 20.04.
Prepare environment
Make sure you have installed Node.js and npm. You can read post how to install them.
Install TypeScript
Run the following command to install TypeScript:
sudo npm install -g typescript
You can check TypeScript version:
tsc --version
Testing TypeScript
Create a main.ts
file:
nano main.ts
Add the following code in a file:
console.log('Hello world');
Convert TypeScript code to JavaScript:
tsc main.ts
A new file named main.js
is generated. Now you can run it with node
command:
node main.js
Uninstall TypeScript
You can completely remove TypeScript using the following command:
sudo npm uninstall -g typescript
Leave a Comment
Cancel reply