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

This function reducer uses an exhaustiveness check. After adding a new member `{ kind: "triangle"; base: number; height: number }` to the `Shape` union but WITHOUT adding a `case` for it, where does TypeScript report the error?

type Shape = | { kind: "circle"; r: number } | { kind: "square"; s: number }; function area(sh: Shape): number { switch (sh.kind) { case "circle": return Math.PI * sh.r ** 2; case "square": return sh.s ** 2; default: { const _exhaustive: never = sh; return _exhaustive; } } }