β Fullstack with Vue.jsQuestion 20 of 62
What is a discriminated union?
π Explanation
A discriminated union is a union of object types sharing a common literal property (like kind), which lets TypeScript narrow the type safely based on that property's value, as shown with the circle vs other shape check. The other options describe things unrelated to this concept: overload selection by parameter names, excluding null/undefined, and unions of primitives don't involve a shared discriminant property at all.
Related questions
β PreviousNo login needed