TypeScript · Junior · Question 39 of 75
How do you extend an interface?
- ✓Correct answer:
interface Admin extends User { role: string } - 2
interface Admin implements User { role: string } - 3
interface Admin = User + { role: string }
Explanation
An interface is extended with extends (from several at once: extends A, B). implements is used by classes to guarantee they match an interface. For type aliases, the counterpart is an intersection User & { role: string }.