Practical Decision Tree: When to Choose Which
You'll learn: A step-by-step decision process for choosing between interface and type in real-world TypeScript code.
The Decision Framework
Now that you've seen all the differences, let's distill them into a practical guide you can follow every time you write a type.
Start Here: What Are You Defining?
Is it an object shape? (Properties and methods describing a data structure)
- YES → Prefer
interfaceby default- Clearer error messages
- Better performance
- Can be extended or merged later if needed
- Follows community conventions
Is it a union or intersection of types?
- YES → Use
type(interfaces can't represent unions)
Is it a primitive, literal, or tuple?
- YES → Use
type(interfaces don't support these)
The Public API Test
Will this be consumed by other modules or packages?
- YES → Strongly prefer
interface- Declaration merging allows users to augment your types
- Named interfaces produce friendlier error messages
- Signals extensibility to your consumers
Is this internal utility logic or a helper type?
- YES →
typeis fine- Unions, intersections, and mapped types work better
- No need for external extensibility
Examples in Context
// Public API: interface
interface UserConfig {
theme: string;
timeout: number;
}
// Union for internal logic: type
type Status = "pending" | "success" | "error";
// Utility helper: type
type Nullable<T> = T | null;
Key Takeaway: Use interface for object shapes you want to be public and extensible; use type for unions, primitives, and internal utilities where flexibility matters more than merging.