JavaScript Internals (521 Qs)•Part 5: ES6+ Modern Syntax, Classes, Modules & Destructuring (254 - 328)
What is typescript
TypeScript is a typed superset of JavaScript created by Microsoft that adds optional types, classes and many other features, and compiles to plain JavaScript. Angular is built entirely in TypeScript and it is used as the primary language there. You can install it globally as
bash
npm install -g typescript
Let's see a simple example of TypeScript usage,
typescript
function greeting(name: string): string {
return "Hello, " + name;
}
let user = "Alex";
console.log(greeting(user));
The greeting method allows only string type as argument.