Skip to content

Type Alias

In one line

A type alias is a name for a type, created with the `type` keyword. It can alias primitives, unions, intersections, tuples, and object types.

In simple words

A type alias gives a name to a type. You create it with type Name = .... Unlike interfaces, type aliases can represent unions, intersections, tuples, and primitive types — not just object shapes.

Type aliases are erased at compile time, just like interfaces. They cannot be merged (unlike interfaces), but they are more flexible in what they can represent.

Use type aliases for unions (type Status = "active" | "inactive"), intersections (type A & B), tuples (type Pair = [string, number]), and primitive aliases (type ID = string). Use interfaces for object shapes that might need declaration merging or extension.

Example

typescript
type Status = "active" | "inactive" | "pending";
type ID = string | number;
type Pair = [string, number];

const status: Status = "active";
const id: ID = 123;

Type aliases for a string union, a string|number union, and a tuple.

Common confusions

  • Confused with: interface

    The difference: Type aliases can represent unions and tuples; interfaces cannot. Interfaces support declaration merging; type aliases cannot.

Related terms

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary