Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumTypeScriptdiscriminated unionsSingle-choice MCQ

Given a `Result` discriminated union keyed on a boolean literal, which property is accessible without error in each branch?

type Result = | { ok: true; value: number } | { ok: false; error: string }; function unwrap(res: Result) { if (res.ok) { /* branch A */ } else { /* branch B */ } }