Type Aliases, Unions & Intersections in TypeScript

From the TypeScript cheat sheet ยท Basic Types ยท verified Jul 2026

Type Aliases, Unions & Intersections

Create custom types with aliases, combine with unions and intersections

typescript
// Type alias
type ID = string | number;

// Union (one of)
type Status = "active" | "inactive" | "pending";

// Intersection (combine all)
type Employee = Person & { company: string };
๐Ÿ’ก Union (|) means "one of these" โ€” intersection (&) means "all of these combined"
โšก Literal types restrict values to exact strings, numbers, or booleans
๐Ÿ“Œ Intersections merge all properties โ€” conflicting properties become never
๐ŸŸข Use type aliases for unions/intersections; use interfaces for object shapes you might extend

More TypeScript tasks

Back to the full TypeScript cheat sheet