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

Why does the assignment to `e` on the last line fail to type-check?

type Event = | { type: "click"; x: number; y: number } | { type: "key"; key: string }; function handle(e: Event) { if (e.type === "click") return; const e2: { type: "click"; x: number; y: number } = e; }