Your First TypeScript Program
Every TypeScript program you write will use console.log() constantly, exactly like JavaScript — it's how your code talks back to you. The one thing that's different from plain JavaScript is what happens before your code runs.
Type-checking happens first
When you hit run, TypeScript's compiler reads your entire file and checks every type before executing a single line. If there's a type error anywhere, nothing runs at all — you get a compile error instead of output. Get the types right, and your code runs exactly like the equivalent JavaScript would.
Comments
Comments work exactly like JavaScript: anything after // on a line is ignored completely, and they exist purely so humans reading the code later understand why something is written the way it is.
Run it yourself
Here's a small program with a comment and two console.log() calls. This was actually executed to get the output shown below — try changing the text and running it yourself using the button under the example.
// This is a comment - TypeScript ignores it
console.log("Hello, World!");
console.log("Welcome to TypeScript.");Hello, World! Welcome to TypeScript.
Next: basic types — how to describe the shape of a value, and what TypeScript actually catches for you.
Practice exercise
Add a comment above your code, then print "Learning TypeScript one step at a time."