What is TypeScript?

TypeScript is a typed superset of JavaScript created by Microsoft that adds optional types, classes, async/await, and many other features, and compiles to plain JavaScript. Angular built entirely in TypeScript and used as a primary language. You can install it globally as

npm install -g typescript

Let's see a simple example of TypeScript usage,

function greeter(person: string) {
return 'Hello, ' + person;
}
let user = 'Sudheer';
document.body.innerHTML = greeter(user);

The greeter method allows only string type as argument.


April 22, 2022
1387