What is TypeScript, and how is it different from JavaScript?

Answer

TypeScript is a superset of JavaScript that adds static typing and other features like interfaces, enums, and advanced tooling capabilities. TypeScript code compiles to plain JavaScript, ensuring compatibility with JavaScript environments.

// TypeScript
let greeting: string = "Hello, TypeScript!";
console.log(greeting);

// JavaScript (compiled)
var greeting = "Hello, TypeScript!";
console.log(greeting);

Read more about TypeScript