TypeScript · Junior · Pytanie 39 z 75
Jak rozszerzyć interfejs?
- ✓Poprawna odpowiedź:
interface Admin extends User { role: string } - 2
interface Admin implements User { role: string } - 3
interface Admin = User + { role: string }
Wyjaśnienie
Interfejs rozszerza się przez extends (z kilku naraz: extends A, B). implements stosują klasy, by zagwarantować zgodność z interfejsem. Dla aliasów typów odpowiednikiem jest przecięcie User & { role: string }.