TypeScript
Types as a set
Types can be viewed as sets of possible values. Narrowing makes the set smaller.
Nesting
string[]
boolean[]
[string, number]
Array<{ size: number }>Narrowing example
type Id = string | number;
function print(id: Id) {
if (typeof id === "string") {
id.toUpperCase();
}
}