CricketScript Lesson 1 of 11 · Meet the Players

Primitive types

TypeScript's simplest building blocks.

In TypeScript, every value has a type. The three simplest are string for text, number for any number, and boolean for true or false.

TypeScript checks these for you. If you treat a number like text, it tells you — before the bug ships.

Think of a cricket player. Their name is text. Their jersey number is a number. Whether they're the captain is true or false. Three attributes — three types.

Tap Aarav Sharma (AS) — the right-hander with the bat.
AS VS
attribute: type
runs 0

Here's the code.

The same three types you just tapped, written out as TypeScript. Each comment shows the inferred type.

const batter = {
  name: 'Aarav Sharma',         // string
  jersey: 7,              // number
  isCaptain: true,       // boolean
};

Three types, three attributes.

You just used three TypeScript primitive types: a name is a string, a jersey number is a number, and the captain flag is a boolean.

Every value in your TypeScript code is one of a small set of types. Today you met the three simplest. The rest of the lessons build on these.

Beta preview — free while in beta

All 11 lessons are open. No signup, no payment, no gate. I'm iterating on the lessons for a few weeks before the full release — everything you see is free during that window.

Spotted a bug or have a suggestion? Email [email protected] — beta feedback is the whole point.