Interfaces in TypeScript
From the TypeScript cheat sheet · Interfaces & Classes · verified Jul 2026
Interfaces
Define object shapes and contracts for type checking
typescript
// Basic interface
interface User {
name: string
age: number
email?: string // Optional
readonly id: number // Readonly
}
// Extending interfaces
interface Admin extends User {
role: string
permissions: string[]
}
// Function in interface
interface Greetable {
name: string
greet(): void
}
// Index signatures
interface StringDictionary {
[key: string]: string
}💡 Interfaces can be extended and merged
📌 Use interfaces for object shapes
✅ Prefer interfaces over type aliases for objects