Defining Object Shapes with Interfaces
Use interface to describe object structure.
Welcome
Interfaces describe the shape of objects in TypeScript. They define which properties exist, their types, and whether they are optional or readonly.
Basic Interface
Define an interface with the `interface` keyword followed by property names and their types.
interface User {
id: number;
name: string;
email: string;
}
const alice: User = { id: 1, name: 'Alice', email: 'a@b.com' };All lessons in this course
- Defining Object Shapes with Interfaces
- Type Aliases for Complex Types
- Interface Extension and Merging
- Interface vs Type: When to Use Each