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
attributetype
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.

Enjoyed this? Nine more lessons plus a bonus await.

This is one of two free preview lessons — Lessons 1 and 9. The other 9 lessons + the bonus finale unlock with the full course.

$15worldwide · ₹625India (50% off)
Unlock the rest of the course →
30-day money-back guarantee · Lessons 1 and 9 stay free either way
Made by one person, not a company. Questions: [email protected]