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

Inside the `if (r.data)` branch, what is the type of `r.status`?

type Resp = | { status: "success"; data: string; error?: undefined } | { status: "error"; error: string; data?: undefined }; function f(r: Resp) { if (r.data) { return r.status; } return r.status; }