Skip to the workspace
Pebellslearn by building
TypeScript Interfaces  ›  Lesson

Types vs Interfaces

Types vs Interfaces 12 minInterfaces describe object shapes and can be reopened and extended; type aliases can name any type, including unions and tuples, but cannot be reopened.

typescript / Types vs Interfaces

Explore each scene at your own pace.

01 · The rule

The rule

Types vs Interfaces

Interfaces describe object shapes and can be reopened and extended; type aliases can name any type, including unions and tuples, but cannot be reopened.

Compare extension, declaration merging and union support before choosing a declaration form.

type Task = {...} and interface Task {...} both work, and teams argue about which to use. The practical answer is short: they overlap for object shapes, and each has a few things only it can do. Learn those few things and the choice becomes easy.

The rule

Interfaces describe objects and can be reopened; aliases name anything but are closed.

Where they are the same. For a plain object shape, these are interchangeable:

interface TaskA { id: number; title: string }
type TaskB = { id: number; title: string };

Both support optional and readonly members, methods, and being implemented by a class. Both are erased at compile time.

Only a type alias can name something that is not an object shape:

type Status = "todo" | "doing" | "done";   // union
type Pair = [number, string];               // tuple
type TaskId = number;                        // primitive
type TaskFilter = (t: TaskA) => boolean;     // function type

Only an interface can be reopened. Declaring the same interface name twice merges the members, which is called declaration merging:

interface Settings { theme: string }
interface Settings { pageSize: number }
// Settings now has both theme and pageSize

Doing the same with type is a duplicate-name error. Merging is how you add fields to types you do not own, such as the browser's Window or a library's options interface.

Extending. Interfaces use extends and report conflicting members as errors. Aliases combine with &, where a conflict quietly becomes never.

Many teams settle on a simple convention: interfaces for object shapes, type aliases for everything else. Others use aliases everywhere for consistency. Either is fine if applied consistently.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.