Break Interfaces
👨💼 You now understand interfaces and when to use them!
You learned:
- 📋 Interface syntax for defining object shapes
- ↔️ Differences between interfaces and type aliases
- 🔗 Extending interfaces to build on existing shapes
- 🏗️ Declaration merging for library extensibility
🦉 A pragmatic approach:
// Use types for everything
type User = {
name: string
}
type Status = 'active' | 'inactive'
type Point = [number, number]
type ID = string
// Use interfaces only for declaration merging when necessary
declare global {
interface Config {
apiUrl: string
}
}
// Later augmented via declaration merging
declare global {
interface Config {
theme: 'light' | 'dark'
}
}
Test Your Knowledge
Retrieval practice helps solidify learning by actively recalling information. Use this prompt with your AI assistant to quiz yourself on what you've learned.
Please quiz me on exercise 7 using the epicshop MCP server. Call the get_quiz_instructions tool with exerciseNumber "7" to get the quiz instructions, then quiz me one question at a time.