Intermediate
TypeScript
Q47 / 100
What is a discriminated union in TypeScript?
Correct! Well done.
Incorrect.
The correct answer is A) A union of types that share a common literal property used to narrow the type
A
Correct Answer
A union of types that share a common literal property used to narrow the type
Explanation
Discriminated unions use a shared literal "tag" property (e.g. kind: "circle" | "square") that lets TypeScript narrow the union in conditionals.
Progress
47/100