Interfaces vs Type Aliases
Compare interfaces and type aliases: both can describe shapes, but they differ in extension, merging, and advanced cases.
Interfaces vs Type Aliases is a free TypeScript Academy lesson on CoddyKit — lesson 2 of 3. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the TypeScript Academy learning path, one of 3 lessons in the course, and your progress syncs across the web and the CoddyKit app.
Intro
Goal: Understand when to use interfaces vs type aliases. Both describe shapes, but they differ in features and use cases.
Basic interface
Interfaces declare object shapes, can extend other interfaces, and support merging across declarations.
interface User {
id: number;
name: string;
}
const u: User = { id: 1, name: "Ada" };Basic type alias
Type aliases can represent object shapes just like interfaces, but they also support unions, intersections, and primitives.
type User = {
id: number;
name: string;
};
const v: User = { id: 2, name: "Lin" };Merging
Interfaces support declaration merging: multiple declarations combine automatically. Type aliases cannot merge this way.
interface A { x: number; }
interface A { y: number; }
const obj: A = { x: 1, y: 2 };Unions with type
Type aliases shine when combining unions or intersections. Interfaces cannot directly create unions.
type Shape = Circle | Square;
type Circle = { kind: "circle"; radius: number };
type Square = { kind: "square"; size: number };When to choose
Guidelines:
- Use interfaces for public APIs and OOP-style extension.
- Use type aliases for unions, intersections, or advanced compositions.
- Both are valid for objects; prefer consistency in a codebase.
Interfaces vs Types check
Quick check: Which statement is TRUE about interfaces vs type aliases?
Recap
Recap: Interfaces and type aliases both describe shapes. Interfaces merge and extend, type aliases compose unions/intersections. Pick based on needs.
Frequently asked questions
Is the “Interfaces vs Type Aliases” lesson free?
Yes — the full text of “Interfaces vs Type Aliases” is free to read here on the web, and the TypeScript Academy course includes 3 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the TypeScript Academy course, upgrade to CoddyKit PRO.
What will I learn in “Interfaces vs Type Aliases”?
Compare interfaces and type aliases: both can describe shapes, but they differ in extension, merging, and advanced cases. You practise TypeScript Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.
Do I need any experience to start TypeScript Academy?
No prior experience is required. TypeScript Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 2 of 3, so you can start here or from the beginning and move at your own pace.
How long does the “Interfaces vs Type Aliases” lesson take?
Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.
Can I write and run code in this TypeScript Academy lesson?
Yes. Every TypeScript Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.
All lessons in this course
- Object types, optional/readonly, index signatures
- Interfaces vs Type Aliases
- Structural typing & excess property checks