Break Intersection Types
π¨βπΌ You've learned to combine types with intersections!
You learned:
- β
&operator combines types - π§© Composing types from building blocks
- π Intersection vs extension - similar but different
- π‘ Flexibility - works with type aliases, not just interfaces
π¦ Intersections vs extends:
// Using intersection
type User = BaseEntity & { name: string }
// Using interface extends
interface User extends BaseEntity {
name: string
}
Both work. Intersections are more flexible (work with unions, type aliases),
while
extends is more explicit about the hierarchy.Next up:
any vs unknownβhandling uncertain types safely!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 4 using the epicshop MCP server. Call the get_quiz_instructions tool with exerciseNumber "4" to get the quiz instructions, then quiz me one question at a time.