TypeScript Introduction
TypeScript is JavaScript with types. You write almost the same code, but you can label what kind of value each thing holds — a number, a string, and so on. TypeScript then warns you when you use a value the wrong way, catching bugs before they run.
Add a type with a colon after the name. This editor transpiles your TypeScript to JavaScript and runs it — press Run and watch the console:
let age: number = 30
let name: string = "Sam"
console.log(name, "is", age)
Try it yourself
Loading editor…