TypeScript · Lesson 4 of 120
Your First Program
Hello, TypeScript.
Let's write a real TypeScript program. A few variables with types, and a message built from them. The syntax is a colon, then the type, right after the name.

- A few variables
- Colon, then the type
- A message
Hello, TypeScript
Shop is a string, bikes is a number, and open is a boolean, meaning true or false. Then we print a message using all three. Run it. TypeScript checked every type, and the program ran.
app.tstypescript
const shop: string = "Northwind Bikes";
const bikes: number = 12;
const open: boolean = true;
console.log(`${shop} has ${bikes} bikes in stock.`);
console.log("Open today?", open);Output
Northwind Bikes has 12 bikes in stock. Open today? true
The pattern
Name, colon, type, equals, value. Const means the variable won't be reassigned. Let means it can change. Template strings, with backticks, put values inside text.
| key | value |
|---|---|
| Pattern | name: type = value |
| const | never reassigned |
| let | can change |
| `${x}` | values in text |
Summary
Write a colon and a type after a variable's name. Next, reading type errors.
Key takeaways- name: type
- const and let
- Template strings
Next up: Reading Type Errors — what tsc tells you