Course contentsShow
← TypeScript
Lesson 374 of 1,7968. Interfaces vs Type AliasesFree lesson

Primitive and Literal Types: Only Type Aliases Work

Type aliases can alias primitives, unions of literals, and tuples; interfaces are strictly for object shapes.

Primitive and Literal Types: Only Type Aliases Work

What you'll learn: You'll discover why type aliases are your only option when working with primitives, literals, and tuples—something interfaces simply cannot do.

The Core Limitation

Interfaces are designed exclusively for describing object shapes. They define properties, methods, and index signatures—that's their entire purpose. Type aliases, on the other hand, can alias anything: primitives, literal values, unions of literals, tuples, and yes, object shapes too.

When you need to give a meaningful name to a primitive type, a string literal union, or a fixed-length tuple, interfaces are powerless. Only type aliases can handle these scenarios.

Why This Matters

Think of interfaces as blueprints for buildings (objects)—they describe rooms and features. Type aliases are like labels that can go on anything: buildings, individual bricks (primitives), specific colors (literals), or neatly packaged sets (tuples).

// ✅ Type alias: Can alias a primitive
type UserId = number;

// ✅ Type alias: Can alias literal unions
type Status = "pending" | "approved" | "rejected";

// ✅ Type alias: Can alias a tuple
type Coordinates = [number, number];

// ❌ Interface: Cannot do any of the above
// interface UserId = number;  // Syntax error!
// interface Status = "pending" | "approved";  // Nope!

If you try to use an interface for primitives or literals, TypeScript will reject it outright—it's simply not what interfaces are built for. This isn't a weakness; it's a design choice that keeps interfaces focused on their specialty: object contracts.

Key Takeaway: Interfaces only describe object shapes; when you need to alias primitives, literal unions, or tuples, type aliases are your only tool.