Recall & Review
beginner
What is an intersection type in TypeScript?
An intersection type combines multiple types into one. It means a value must satisfy all the combined types at the same time.
Click to reveal answer
beginner
How do you write an intersection type in TypeScript?
Use the ampersand (&) symbol between types. For example:
type A = Type1 & Type2;Click to reveal answer
intermediate
What happens if two intersected types have conflicting properties?
TypeScript will require the property to satisfy both types. If conflicts can't be resolved, it causes a type error.
Click to reveal answer
beginner
Example: What does this type mean? <br>
type Person = { name: string } & { age: number };It means a
Person must have both a name (string) and an age (number).Click to reveal answer
intermediate
Can intersection types combine interfaces and types?
Yes, you can intersect interfaces and type aliases together using & to create a new combined type.
Click to reveal answer
Which symbol is used for intersection types in TypeScript?
✗ Incorrect
The ampersand (&) symbol is used to combine types into an intersection type.
What does this intersection type require? <br>
{a: number} & {b: string}✗ Incorrect
Intersection means the object must have both properties a and b.
Can intersection types be used to combine primitive types like string & number?
✗ Incorrect
Intersecting incompatible primitive types like string & number results in the never type, meaning no value can satisfy both.
If two intersected types have the same property with different types, what happens?
✗ Incorrect
Conflicting property types in intersection cause a type error because no value can satisfy both.
Which of these is a valid intersection type?
✗ Incorrect
Only the ampersand (&) is valid for intersection types.
Explain in your own words what an intersection type is and how it is used in TypeScript.
Think about how two sets overlap and what belongs to both.
You got /3 concepts.
Describe a situation where using an intersection type would be helpful in a program.
Imagine you want an object that has features from two different things.
You got /3 concepts.