TypeScript · Middle · Question 74 of 75
Does narrowing work when a discriminated union is destructured first?
const { kind, radius } = shape;
if (kind === 'circle') radius.toFixed();- ✓Correct answer: Since TS 4.6, destructured discriminants narrow related destructured properties too (for
constdestructuring) - 2It never narrows; you must use
shape.kind - 3It narrows only in
switchstatements
Explanation
The destructured variables must be const (or unmodified parameters) for control-flow analysis to connect them.