Warm-up1 / 1
Can you write this from memory?
Create Admin interface extending User with role: string
In TypeScript, both interface and type can define object shapes, but they're not interchangeable. Interfaces support declaration merging and extends. Types handle unions, tuples, and mapped types.
This page covers the decision points. For a side-by-side comparison with a quick decision table, see the interfaces vs types cheat sheet.
What You'll Practice: TypeScript Interface vs Type: When to Use Each
Choose between interface and type for object shapesExtend interfaces with extendsCompose types with intersection (&)Use declaration merging for library augmentationRecognize TS 5 behavior differences
TypeScript Interface vs Type: When to Use Each Sample Exercises
Example 1Difficulty: 1/5
Fill in the type for the name property (it holds text)
stringExample 2Difficulty: 1/5
Fill in the return type for the greet method
stringExample 3Difficulty: 2/5
Fill in the character to make the email property optional
?+ 3 more exercises
Quick Reference
TypeScript Interface vs Type: When to Use Each Cheat Sheet →Copy-ready syntax examples for quick lookup