Introduction

Typescript is a strongly-typed superset of JavaScript and it makes it more readable and maintainable. This is an open-source language created by Microsoft. A similar way of writing syntax similar C# OOPs concept. Typescript can be used for cross-browser development.

What are the features?

How to Install

We can install Typescript two ways
  1. Using npm (Node.js Package Manager)
  2. Install in Visual Studio
How to install using npm
First, we have to install the node.js. Download it from this location.
https://nodejs.org/en/download/
TypeScript
Now, we can check if it has installed or not with the below command.
node –v
TypeScript
It will display the version of the installed node.js.
Then use the below command in the command prompt to install the TypeScript.
npm install -g typescript
TypeScript
TypeScript
How to install in visual studio
We have to go to the following location.
https://www.microsoft.com/en-us/download/details.aspx?id=48593
After that, we will see a window.
TypeScript
And click the download button.
And start the installation after download.
TypeScript
After that click the run button.
TypeScript
After that click the install button -> Click Yes button.
TypeScript
After completing installation we can check in Visual Studio if it is installed or not.
First, open Visual Studio and go to the help option on the menu.
TypeScript
And also we can check the below.
TypeScript

Way of writing syntax

We can first see how we can write it in JavaScript.
  1. var number1 = 5;
  2. var number2 = 5;
  3. var str = "Hello";
  4. var something = 890;
  5. var lst = [1, 2, 3, 4, 5];
  6. function Add(number1, number2) {
  7. return number1 + number2;
  8. }
We can see how we can write it in TypeScript.
  1. var number1: number = 5;
  2. var number2: number = 5;
  3. var str: string = "Hello";
  4. var something = 890;
  5. var lst: Array < number >= [1, 2, 3, 4, 5]
  6. function Add(number1: number, number2: number) {
  7. return number1 + number2;
  8. }
TypeScript
Summary
TypeScript generates plain JavaScript code and we can use it with any browser. TypeScript features are similar to object-oriented programming languages such as classes, interfaces, inheritance, overloading, and modules. We can write and organize our JavaScript code making it more maintainable and extensible.