TypeScript · Junior · Question 10 of 75
What does the intersection type Admin = User & { role: 'admin' } give you?
- ✓Correct answer: A type with all the properties of
Userplusrole: 'admin' - 2A type with only the properties common to
Userand the object withrole - 3A type that can be either
Useror{ role: 'admin' }
Explanation
An intersection combines requirements: the value must satisfy both types. It's a way to compose types, similar to interface Admin extends User. Conflicting properties produce never for that property.