TypeScript Blog
Learn Online Quick Tips

What Makes TypeScript Essentially Different?

Introduction 

TypeScript is a strongly typed language, which means that the compiler checks that your code matches the types it expects. It also supports features like classes, interfaces, and generics on the front end which are available in other popular languages like C#, Ruby, and Java. TypeScript can be run on any browser and any host. It is a superset of JavaScript, which means that it can be used as an alternative to JavaScript in some situations. 

What is TypeScript? 

TypeScript supports JavaScript features like dynamic typing, classes, interfaces and Async programming. 

It is a typed superset of JavaScript, which means that it is a language that compiles to plain JavaScript. It also supports features like dynamic typing, classes, and interfaces. Async programming with promises has been added to the language to make asynchronous methods more convenient than callbacks. 

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? 

  1. 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. 
  1. It  is a superset of JavaScript. It adds features that make it easier to use, but still compatible with the ECMAScript standard (the language in which JavaScript was defined). 
  1. 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. 
  1. It is a multi-paradigm language that supports both object-oriented and functional programming. It’s especially useful for building client-side applications, but it can also be used to build server-side applications by transpiling the TypeScript code into JavaScript. 
  1. It is supports many of the same features as JavaScript: data types, functions, and classes; inheritance; optional typing via interfaces; etc. However, TypeScript adds some new features as well: classes (structs), interfaces (decorators) and async/await support. 

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! 

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 Infraveo.” 

JavaScript 

// Save the file as index.ts 

var greet: string = “Greetings”; 

var infraveo: string = “Infraveo”; 

console.log(greet + ” from “ + infraveo); 

Step to compile: 

tsc index.ts

Step to Run :

node index.js

Output:

Greetings from Infraveo 

Conclusion 

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!