TypeScript was created by Microsoft in 2010, and its first version was released to the public in 2012
The main purpose of TypeScript is to make JavaScript development easier and more reliable, by adding static typing and other features that can help catch errors, improve tooling, and support modern syntax.
TypeScript code can be compiled to plain JavaScript, which can run on any browser or platform that supports JavaScript
What uses TS
Angular, a popular framework for building web and mobile applications
React, a library for creating user interfaces
Deno, a secure runtime for JavaScript and TypeScript
VS Code, a code editor that supports many languages and features
Here is an example of TS
interface Person {
name: string;
age: number;
}
function greet(person: Person) {
return `Hello, ${person.name}.
You are ${person.age} years old.`;
}
let user: Person = {
name: "Alice",
age: 25,
};
console.log(greet(user));