• Last Updated : 27 Sep, 2023

TypeScript is a strict superset of JavaScript, which means anything that is implemented in JavaScript can be implemented using TypeScript along with the choice of adding enhanced features. It is an Open Source Object Oriented programming language and strongly typed language. As TS code is converted to JS code it makes it easier to integrate into JavaScript projects.

TypeScript Tutorial

For a large-scale project adopting It might result in more robust software, while still being deployable where a regular JavaScript application would run. It won’t make your software bug-free. But it can prevent a lot of type-related errors. Along with the Clever IntelliSense. A simple code example will help you to understand the need for this strongly typed programming language.


Note: Reasons to pick TypeScript over JavaScript.


Reason to learn TypeScript?

JavaScript was initially developed to be a lightweight easy-to-learn language mainly focusing on simple DOM manipulations but the standards changed with time and that is where TypeScript came into the picture as it adds enhanced features to JavaScript.

  • The use of TypeScript in popular JavaScript Frameworks and Libraries.
  • It adopts the basic building blocks of your program from JavaScript. All TS code is converted into its JS equivalent for the purpose of execution.
  • The support for Classes and Objects is also one of the main reasons for its increasing popularity as it makes it easier to understand and implement OOPS concepts as compared to the standard prototype-based implementation provided by native JavaScript.

TypeScript Installation: Browsers natively do not understand typescript, but they understand javascript. So in order to run the codes, first it is transpiled to javascript.

You can install it by running the following command.

npm install -g typescript

Let’s understand the working of the code using an example.

Example: In this example, we are creating a basic example that will print “Greetings from GeeksforGeeks”.


// Save the file as index.ts
var greet: string = "Greetings";
var geeks: string = "GeeksforGeeks";
console.log(greet + " from " + geeks);

Step to compile: To compile the code, we can run the following command on the command line.

tsc index.ts

Step to run: Run the javascript file using the following command on the command line:

node index.js


Greetings from GeeksforGeeks

P.S: To continue this tutorial go along with an organized left bar, that will help you to understand this tutorial in a better way.

Learn more about TypeScript:

Recent articles on TypeScript

Please write comments if you find anything incorrect, or if you want to share more information about the topic discussed above.