Back

Type Aliases

Type aliases create a custom name for a type. Similar to interfaces but more flexible: you can use them for primitives, unions, and more.

// Simple alias
type ID = string | number

// Object type
type Point = {
  x: number
  y: number
}

// Union type
type Status = "active" | "inactive" | "pending"

const userStatus: Status = "active"
// const bad: Status = "unknown" // ERROR

Roadmap