TypeScript Interfaces vs Types: The Complete Guide
One of the most common questions TypeScript developers face: "Should I use an interface or a type?" Let's break down the differences.
What Are Interfaces?
Interfaces define the shape of an object, designed for object-oriented programming.
interface User {
id: number;
name: string;
email: string;
}
const user: User = {
id: 1,
name: "John Doe",
email: "john@example.com"
};What Are Type Aliases?
Type aliases can represent any type: primitives, unions, intersections, tuples, and objects.
type User = {
id: number;
name: string;
};
// Also represents other types
type ID = string | number;
type Callback = (data: string) => void;Key Differences
1. Declaration Merging
Interfaces support declaration merging - declare the same interface multiple times.interface Window {
title: string;
}
interface Window {
ts: TypeScriptAPI;
}
// Result: Window has both properties2. Extending vs Intersection
Interfaces useextends:
interface Animal {
name: string;
}
interface Dog extends Animal {
breed: string;
}&):
type Animal = { name: string };
type Dog = Animal & { breed: string };3. Union Types
Types can represent unions, interfaces cannot:type Status = "pending" | "approved" | "rejected";
type ID = string | number;When to Use What?
Use Interfaces:
- Defining object shapes for classes
- Need declaration merging
- Building public APIs
Use Types:
- Unions or intersections
- Utility types
- Primitive aliases or tuples
Real-World Example
interface User {
id: string;
name: string;
}
type ApiResponse<T> =
| { status: "success"; data: T }
| { status: "error"; error: string };
type UserResponse = ApiResponse<User>;
// React Component
interface BaseButtonProps {
children: React.ReactNode;
onClick: () => void;
}
type ButtonVariant = "primary" | "secondary";
type ButtonProps = BaseButtonProps & {
variant?: ButtonVariant;
};Conclusion
- Interfaces: Object shapes, class contracts
- Types: Unions, primitives, transformations
Default to interfaces for objects, use types for everything else!
Topic Hub
Frontend Architecture / Tooling
Architecture, platform choices, and AI-assisted development workflows.
Open Frontend Architecture / Tooling hubRelated Reading
14 min read
Serverless & Edge Architecture for Full-Stack Apps
Master serverless and edge computing patterns for building scalable, cost-effective full-stack applications. Learn when to use each approach and how to implement them.
12 min read
AI-Assisted Development Tools Every Web Developer Should Use in 2025
Discover the AI-powered tools transforming web development workflows, from code generation to design-to-code, and how to integrate them effectively.
Need a frontend roadmap that supports growth, not churn?
I help product and marketing teams simplify stack decisions, reduce frontend drag, and ship faster without creating long-term maintenance debt.
Written by Salman Izhar
Frontend Developer specializing in React, Next.js, and building high-converting web applications.
Learn More