█
LastWrite
  • > Curriculum
  • > Pricing
  • > For Educators
  • > About
  • > Contact
Log InGet Started

Questions, concerns, bug reports, or suggestions? We read every message, write to us at [email protected].

More ways to reach us →
LastWrite

Structured computer science lessons for aspiring developers and security professionals.

[email protected]

(201) 785-7951

Mon–Fri, 9 AM–5 PM EST

Learn

  • Curriculum
  • Pricing

Company

  • About
  • For Educators & Schools
  • Contact Us

Legal

  • Terms of Service
  • Privacy Policy
© 2026 LastWrite. All rights reserved.
Curriculum/Programming Languages/TypeScript/Interfaces vs Type Aliases
35 minIntermediate

Interfaces vs Type Aliases

After this lesson, you will be able to: Decide between interface and type alias; understand declaration merging and extension.

One of TS's daily decisions. The honest answer: mostly equivalent; small differences matter at scale.

Prerequisites:Functions

Both work; here's the difference

`type` = type alias. Can represent ANYTHING (primitives, unions, intersections, computed types). `interface` = object shape only. Can be extended + augmented across files (declaration merging). Most teams use either; consistency matters more than choice.

When to use which

Practical rules.

tsx
// Object shape that might be extended, interface
interface User {
id: string;
name: string;
}
interface AdminUser extends User {
permissions: string[];
}
// Anything else, type alias
type Id = string | number;
type Status = "active" | "closed";
type Tuple = [string, number];
type Callback = (x: string) => void;
// Union of objects, must be `type`
type Result = { ok: true; data: User } | { ok: false; error: string };
// Both can describe object shape, these are equivalent in practice:
type U1 = { name: string };
interface U2 { name: string }

Declaration merging (interface-only)

Sometimes useful; usually confusing.

tsx
// Augment a third-party type, common with React, Express
declare module "express-serve-static-core" {
interface Request {
user?: { id: string };
}
}
// Now `req.user` is typed everywhere.
// Same pattern doesn't work with type aliases.

Common mistakes only experienced TS devs avoid

Mixing both in one codebase without convention. Pick one default; document. Using interface for non-objects. Errors. Using type when you need declaration merging (rare). Long Pick/Omit chains when extends would read better.

Quick Check

Which feature is ONLY available on interface, not type alias?

Pick the difference.

Sign in and purchase access to unlock this lesson.

Sign in to purchase
←Functions in TypeScript
Back to TypeScript
Generics→