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

Why does accessing `state.data` on the last line produce a type error?

type State = | { status: "loading" } | { status: "success"; data: string } | { status: "error"; message: string }; function render(state: State) { if (state.status !== "loading") { return state.data; } }