What is TypeScript?
TypeScript has been developed by Microsoft as part of their strategy for writing applications in browser-based technologies such as NodeJS or WebGL applications using C#/.NET languages (C#/.NET Framework).
What are the Advantages of using TypeScript?
- TypeScript allows you to use high-end features like Generics and Modules on the front end which are available in other popular Languages like C#, Ruby, and Java.
- Typescript allows you to use high end features like Generics and Modules on the front end which are available in other popular Languages like C#, Ruby and Java.
Steps to Install TypeScript
To install TypeScript, you need to download the compiler from its official website. This can be done by clicking on the green button provided at the top of this page.
After downloading and installing the compiler, you will have to install its transpiler as well. You can do so by following these steps:
- Download the Typescript compiler from https://www.typescriptlang.org
- Install it on your machine using npm (Node Package Manager) and then run this command in Command Prompt: npm install -g typescript@beta (where “beta” is an identifier for that version).
This should take care of installing all required packages needed by TypeScript as well as their dependencies into the node_modulesder located inside your project directory so that they don’t get mixed up with other files during the compilation process later down the line when working with other external libraries like a jQuery library which is supported through NodeJS framework itself too!
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 Infraveo.”
// Save the file as index.ts
var greet: string = “Greetings”;
var infraveo: string = “Infraveo”;
console.log(greet + ” from “ + infraveo);
Step to compile:
Step to Run :
Greetings from Infraveo
Now you’re ready to start using TypeScript. The best way is to install NodeJS, which enables you to run TypeScript in your browser by using a transpiler like Babel. We hope this article has been helpful and if you have any questions, please leave us a comment below!