TypeScript · Junior · Question 10 of 75

What does the intersection type Admin = User & { role: 'admin' } give you?

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.

Further reading

Problem with a question

TypeScript · Junior · question 10

Test yourself

Take the TypeScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz