C.W.K.
Stream
Quiz · 3 questions

🪢 Unions & Intersections — Combining Types

A | B, A & B, discriminated unions, exhaustiveness, distribution

Level 0Curious
0 XP0/93 lessons0/23 achievements
0/100 XP to next level100 XP to go0% complete

Quiz

01What does string | number describe?
Hint
After if (typeof x === 'string') { /* x is string here */ }, the compiler narrows automatically.
02What is a discriminated union?
Hint
The discriminator field's type is what makes narrowing work — it must be a literal type so each variant has a different value.
03What does it mean that conditional types are 'distributive' over unions?
Hint
Distribution is one of those features where it'd be confusing without examples — write a small conditional type, apply it to a union, and observe what comes out.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.