Type Composition

Composition (🏁 solution)
πŸ‘¨β€πŸ’Ό You've built a type hierarchy from simple building blocks!
πŸ¦‰ This composition approach has benefits:
  • Consistency - All IDs have the same type
  • Flexibility - Change ID from string to number in one place
  • Documentation - Types like Email communicate intent
In the next exercise on intersection types, you'll learn an even cleaner way to compose types without repeating fields.

Please set the playground first

Loading "Type Composition"
Loading "Type Composition"