Runs are limited.
Off a single ball, only certain run totals are legal.
Cricket's scoring grammar is strict. From one delivery, the batters can run a single, a double, a triple — rare but possible — strike a boundary four, or clear the rope for six. Five is impossible. Seven is impossible. The scorebook simply has no slot for them.
A type alias gives that grammar a name. type Run = 0 | 1 | 2 | 3 | 4 | 6 tells TypeScript: any value in this rule must be one of those six numbers. Try to record a 5 or a 7, and the compiler refuses — at write time, not at the scorer's desk.
Tap a legal run to log it. Tap an illegal one to see TypeScript catch the impossible.
Six legal values. The compiler knows.
A type alias is a reusable name for a type expression. Here, Run is a union of six literal numbers — the only values TypeScript will accept.
type Run = 0 | 1 | 2 | 3 | 4 | 6; function record(r: Run): void { /* ... */ } record(1); // ok — quick single record(4); // ok — through the covers record(6); // ok — over the rope record(5); // Argument of type '5' is not assignable // to parameter of type 'Run'. record(7); // Same — 7 isn't in the union either.
Name a grammar. Reuse it.
type Run is a label for "the only values that can come off a single ball." Once the alias exists, every function that takes a Run shares the same guarantee — and every misuse is caught the moment it's typed.
Type aliases shine when a shape repeats: positions on a field, sides of a coin, suit of a card. Name the shape once. TypeScript polices it everywhere.