Programming Languages Section


Card image
Post by Amina Delali, Mars 11th,2021

Some Facts

TypeScript is an exetnetion of javascript language. It adds optional static typing to the language, so the errors may be easily detected. It can be used to develop client and server side javascript applications. TypeScript is a transpiled language to javascript. So any code wrtitten in TypeScript, will be first converted to javascript then executed. The code can be converted in two different ways:

  • each ts (TypeScript) file is converted into a corrresponding js (javascript) file.
  • all ts files will be bundled into one javascript file.

How to install it

  • on Windows: you have to install first node.js. Then, you will use npm (node package manager) to install typescript. For more details, you can check this link.
  • on ubuntu : you have the possibility to either:
    • install a native package using sudo apt install node-typescript command.
    • install it using node. Of course, node.js must be installed first. Then use npm to install TypeScript. For more details, you can check this link.

In the video below, the installation of typescript native package on ubuntu.

The Hello World Example

  • first code: the message "Hello World!" will be printed on the console, using the console.log function. The code is first transpiled to javascript using the TypeScript Checker (tsc). Then, the resulting js file can be run by node.
  • second code: instead of using the "console.log" function, the alert function will be used to pop up a window (alert) with the message "Hello World!". But this time, the resulting javascript code will be run from the browser, by loading the resulting javascript into an html file.

The two versions of the code are explained in the video below:

Something to say ?

If you want to add something about the TypeScript language or about this post, please feel free to do it by commenting below 🙂 .