Your First Program
5 min · TypeScript
Write and run your very first lines of TypeScript, right here on the page.
Enemy 1 of 5
TypeScript is JavaScript with an extra layer on top: type labels that describe what kind of value a variable or function is meant to hold. Everything that runs in JavaScript still applies here — TypeScript doesn't replace JavaScript, it adds checks on top of it, and those type labels get stripped away before the code actually runs, leaving plain JavaScript underneath.
You print a message with console.log — a built-in function that writes whatever you give it to the output. The text goes inside the parentheses and quotes, so it's treated as literal text and not interpreted as code, and the line ends with a semicolon to mark where the instruction finishes.
Press Run to see it. Because TypeScript is checked before it runs, this same setup is what will later let TypeScript catch mistakes — like passing a number where a String was expected — before your program ever executes, not just when it crashes.
Loading editor...