Interfaces vs Type Aliases
Compare interfaces and type aliases: both can describe shapes, but they differ in extension, merging, and advanced cases.
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" };All lessons in this course
- Object types, optional/readonly, index signatures
- Interfaces vs Type Aliases
- Structural typing & excess property checks