Type Aliases
Prerequisites: Union types
A type alias gives a name to any type — not just object shapes like an interface, but also unions, primitives, or anything else.
type ID = string | number;
type Point = { x: number; y: number };
function printId(id: ID) {
console.log(id);
}
For plain object shapes, interface and type are largely
interchangeable — the difference between them is covered in Level 2.