[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"verticals":3,"quiz-typescript-exhaustiveness-checking-never":44,"search-suggestions":60,"quiz-article-typescript-exhaustiveness-checking-never":109,"path-membership-typescript-exhaustiveness-checking-never":301},[4,20,32],{"id":5,"slug":6,"name":7,"tagline":8,"description":9,"accentFrom":10,"accentTo":11,"icon":12,"defaultLocale":13,"locales":14,"features":16,"position":19},"019fe637-3d33-714b-b57f-23e163ffca0c","dev","Web Development","Read it. Run it. Prove it.","A post a day on modern web development — most with an editable playground and a quiz that explains every answer. Free, no account needed.","violet-500","cyan-400","◇","en",[13,15],"fa",{"courses":17,"paths":17,"articles":17,"exams":18,"flashcards":18,"packages":17,"community":17,"certificates":17,"teams":17,"commerce":17},true,false,0,{"id":21,"slug":22,"name":23,"tagline":24,"description":25,"accentFrom":26,"accentTo":10,"icon":27,"defaultLocale":13,"locales":28,"features":30,"position":31},"019fe637-3dc2-754c-8657-0f175bfee7c6","lang","Languages","Learn a language the way you learn a codebase.","Grammar explained the way good documentation explains an API — one idea at a time, each with a quiz.","amber-400","⌘",[13,15,29],"es",{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":17,"packages":18,"community":17,"certificates":17,"teams":18,"commerce":18},2,{"id":33,"slug":34,"name":35,"tagline":36,"description":37,"accentFrom":38,"accentTo":39,"icon":40,"defaultLocale":13,"locales":41,"features":42,"position":43},"7b3c16f2-931d-410e-802e-e1fa4edab7de","soft","Soft Skills","The half of the job nobody wrote documentation for.","Weekly, on the parts of working life that decide more than your code does — first weeks, meetings, interviews, promotions, and the people around you. Written from what actually happens, and recorded as a podcast you can listen to on the walk.","emerald-400","teal-300","◉",[13],{"courses":18,"paths":18,"articles":17,"exams":18,"flashcards":18,"packages":18,"community":17,"certificates":18,"teams":18,"commerce":18},3,{"id":45,"slug":46,"kind":47,"title":48,"description":49,"config":50,"verticalId":5,"vertical":55,"course":52,"_count":56,"access":57,"attempts":59,"questionCount":51},"01a1df1b-28b7-73ec-8987-03096f86c530","typescript-exhaustiveness-checking-never","PRACTICE_QUIZ","Exhaustiveness Checking Quiz","Check how well the `never`-based exhaustiveness pattern stuck — what it catches, what it doesn't, and why the trick works at all.",{"questionCount":51,"timeLimitSec":52,"shuffleQuestions":18,"shuffleOptions":17,"negativeMarking":19,"passScorePct":53,"maxAttempts":52,"revealAnswers":54,"allowFlagging":18,"allowBacktracking":17},8,null,70,"AFTER_SUBMIT",{"slug":6,"name":7},{"questions":51},{"allowed":17,"reason":58},"FREE",[],[61,65,69,73,77,81,85,89,93,97,101,105],{"slug":62,"name":63,"articles":64},"webdev","Webdev",195,{"slug":66,"name":67,"articles":68},"javascript","Javascript",156,{"slug":70,"name":71,"articles":72},"frontend","Frontend",103,{"slug":74,"name":75,"articles":76},"tutorial","Tutorial",85,{"slug":78,"name":79,"articles":80},"css","Css",56,{"slug":82,"name":83,"articles":84},"typescript","Typescript",36,{"slug":86,"name":87,"articles":88},"performance","Performance",33,{"slug":90,"name":91,"articles":92},"programming","Programming",26,{"slug":94,"name":95,"articles":96},"react","React",23,{"slug":98,"name":99,"articles":100},"node","Node",19,{"slug":102,"name":103,"articles":104},"browser","Browser",18,{"slug":106,"name":107,"articles":108},"nextjs","Nextjs",13,{"id":110,"slug":46,"title":111,"subtitle":52,"excerpt":112,"coverUrl":113,"locale":13,"readingMinutes":114,"publishedAt":115,"viewCount":116,"likeCount":19,"commentCount":19,"author":117,"vertical":122,"topic":123,"tags":125,"_count":130,"playground":132,"body":134,"bodyMd":288,"seo":289,"translationGroupId":291,"series":52,"podcastUrl":52,"verticalId":5,"thread":292,"assessments":294,"translations":297,"quiz":299},"01a1df1b-2879-726c-b86f-69cba3a4ecc3","Your switch forgets a case. Exhaustiveness checking catches it.","How to make the TypeScript compiler fail the build when a switch statement doesn't handle every member of a union — using the `never` type.","\u002Fmedia\u002Fcovers\u002Ftypescript-exhaustiveness-checking-never.png",5,"2026-11-27T11:43:55.790Z",7,{"id":118,"name":119,"username":120,"avatarUrl":52,"headline":121},"019fe637-3c25-7088-9034-39c9f15dc3c8","Parsa Jiravand","parsa","Frontend engineer · building bestpractic",{"slug":6,"name":7,"accentFrom":10,"accentTo":11},{"slug":82,"name":124},"TypeScript",[126,127,128,129],{"slug":82,"name":83,"color":52},{"slug":66,"name":67,"color":52},{"slug":90,"name":91,"color":52},{"slug":62,"name":63,"color":52},{"assessments":131},1,{"slug":46,"title":133},"Exhaustiveness checking — interactive playground",{"blocks":135,"version":131},[136,140,143,146,150,153,159,162,165,168,171,174,178,181,184,188,191,195,198,201,205,208,212,215,218,221,224,227,230,233,236,239,242,245,248,251,254,257,260,263,270,273,276,279,282],{"id":137,"html":138,"type":139},"b1","\u003Cp>Someone on your team adds \u003Ccode>&quot;refunded&quot;\u003C\u002Fcode> to the \u003Ccode>OrderStatus\u003C\u002Fcode> union. Three files use that type. Two of them get updated. The third — the one that renders the status badge on the order page — doesn&#39;t.\u003C\u002Fp>","paragraph",{"id":141,"html":142,"type":139},"b2","\u003Cp>It compiles. It ships. A refunded order sits on a customer&#39;s dashboard labeled &quot;Processing&quot; for two weeks, because the \u003Ccode>switch\u003C\u002Fcode> that renders the badge has no idea \u003Ccode>&quot;refunded&quot;\u003C\u002Fcode> exists, falls through to nothing, and renders an empty string.\u003C\u002Fp>",{"id":144,"html":145,"type":139},"b3","\u003Cp>Nobody wrote a bug. Someone just didn&#39;t update every place that needed updating — which is the normal, forgivable thing that happens on every team, every week. The question is whether your type system notices.\u003C\u002Fp>",{"id":147,"html":148,"text":148,"type":149,"level":31},"b4","The fix everyone reaches for first","heading",{"id":151,"html":152,"type":139},"b5","\u003Cp>The instinctive move is a \u003Ccode>default\u003C\u002Fcode> case:\u003C\u002Fp>",{"id":154,"code":155,"type":156,"language":157,"highlight":158},"b6","type OrderStatus = \"pending\" | \"paid\" | \"shipped\" | \"delivered\";\n\nfunction badgeText(status: OrderStatus): string {\n  switch (status) {\n    case \"pending\":\n      return \"Processing\";\n    case \"paid\":\n      return \"Payment received\";\n    case \"shipped\":\n      return \"On the way\";\n    case \"delivered\":\n      return \"Delivered\";\n    default:\n      return \"Processing\"; \u002F\u002F \"it has to be something\"\n  }\n}","code","ts",[],{"id":160,"html":161,"type":139},"b7","\u003Cp>This feels safe. It isn&#39;t. Add \u003Ccode>&quot;refunded&quot;\u003C\u002Fcode> to the union tomorrow, and this function keeps compiling, keeps running, and keeps quietly mislabeling refunded orders as &quot;Processing&quot; — the exact bug from the top of this post, except now it&#39;s load-bearing, because the \u003Ccode>default\u003C\u002Fcode> case was \u003Cem>designed\u003C\u002Fem> to swallow anything unexpected.\u003C\u002Fp>",{"id":163,"html":164,"type":139},"b8","\u003Cp>A \u003Ccode>console.warn\u003C\u002Fcode> in the default branch helps you find out \u003Cem>after\u003C\u002Fem> it&#39;s in production, if anyone&#39;s watching logs. What you actually want is to find out before you hit &quot;merge.&quot;\u003C\u002Fp>",{"id":166,"html":167,"text":167,"type":149,"level":31},"b9","What you want instead: make the gap a compile error",{"id":169,"html":170,"type":139},"b10","\u003Cp>TypeScript already tracks, branch by branch, which members of a union a \u003Ccode>switch\u003C\u002Fcode> has ruled out. Inside the \u003Ccode>default\u003C\u002Fcode> case of a fully-handled switch, the type of \u003Ccode>status\u003C\u002Fcode> isn&#39;t \u003Ccode>OrderStatus\u003C\u002Fcode> anymore — it&#39;s narrowed down to whatever&#39;s left over. If every case was handled, what&#39;s left over is nothing at all: the \u003Ccode>never\u003C\u002Fcode> type, TypeScript&#39;s name for &quot;a value that cannot exist.&quot;\u003C\u002Fp>",{"id":172,"html":173,"type":139},"b11","\u003Cp>That&#39;s the lever. Write a function that only accepts \u003Ccode>never\u003C\u002Fcode>, and call it from the \u003Ccode>default\u003C\u002Fcode> branch:\u003C\u002Fp>",{"id":175,"code":176,"type":156,"language":157,"highlight":177},"b12","function assertUnreachable(x: never): never {\n  throw new Error(`Unhandled case: ${JSON.stringify(x)}`);\n}\n\nfunction badgeText(status: OrderStatus): string {\n  switch (status) {\n    case \"pending\":\n      return \"Processing\";\n    case \"paid\":\n      return \"Payment received\";\n    case \"shipped\":\n      return \"On the way\";\n    case \"delivered\":\n      return \"Delivered\";\n    default:\n      return assertUnreachable(status);\n  }\n}",[],{"id":179,"html":180,"type":139},"b13","\u003Cp>Right now this compiles cleanly, because TypeScript has proven \u003Ccode>status\u003C\u002Fcode> really is \u003Ccode>never\u003C\u002Fcode> by the time it reaches \u003Ccode>default\u003C\u002Fcode> — every other member of the union got its own case above.\u003C\u002Fp>",{"id":182,"html":183,"type":139},"b14","\u003Cp>Now add \u003Ccode>&quot;refunded&quot;\u003C\u002Fcode> to \u003Ccode>OrderStatus\u003C\u002Fcode> and change nothing else:\u003C\u002Fp>",{"id":185,"code":186,"type":156,"language":157,"highlight":187},"b15","type OrderStatus = \"pending\" | \"paid\" | \"shipped\" | \"delivered\" | \"refunded\";",[],{"id":189,"html":190,"type":139},"b16","\u003Cp>The \u003Ccode>badgeText\u003C\u002Fcode> function no longer compiles. TypeScript narrows \u003Ccode>status\u003C\u002Fcode> in the \u003Ccode>default\u003C\u002Fcode> branch to \u003Ccode>&quot;refunded&quot;\u003C\u002Fcode> — one real, leftover case — and \u003Ccode>&quot;refunded&quot;\u003C\u002Fcode> is not assignable to the parameter type \u003Ccode>never\u003C\u002Fcode>. The error points at the exact line, in the exact file, that forgot to handle the new status. Not a runtime log line three weeks from now. A red squiggle before you push.\u003C\u002Fp>",{"id":192,"html":193,"text":194,"type":149,"level":31},"b17","Why \u003Ccode>never\u003C\u002Fcode> is the right tool for this","Why never is the right tool for this",{"id":196,"html":197,"type":139},"b18","\u003Cp>\u003Ccode>never\u003C\u002Fcode> is TypeScript&#39;s type for &quot;this code path cannot be reached&quot; — functions that always throw, infinite loops, and branches a union&#39;s structure has already ruled out. Assigning a value to a \u003Ccode>never\u003C\u002Fcode>-typed parameter is only legal if TypeScript can prove no value is left to assign. That&#39;s precisely what &quot;the switch handled every case&quot; means. You&#39;re not writing a special exhaustiveness feature; you&#39;re pointing a general-purpose type at a question it&#39;s already equipped to answer.\u003C\u002Fp>",{"id":199,"html":200,"type":139},"b19","\u003Cp>It composes the same way with \u003Ccode>if\u003C\u002Fcode>\u002F\u003Ccode>else if\u003C\u002Fcode> chains — narrowing works the same way there:\u003C\u002Fp>",{"id":202,"code":203,"type":156,"language":157,"highlight":204},"b20","function badgeTextIf(status: OrderStatus): string {\n  if (status === \"pending\") return \"Processing\";\n  else if (status === \"paid\") return \"Payment received\";\n  else if (status === \"shipped\") return \"On the way\";\n  else if (status === \"delivered\") return \"Delivered\";\n  else return assertUnreachable(status);\n}",[],{"id":206,"html":207,"type":139},"b21","\u003Cp>Same guarantee, same failure mode when you add \u003Ccode>&quot;refunded&quot;\u003C\u002Fcode> without touching this function.\u003C\u002Fp>",{"id":209,"html":210,"text":211,"type":149,"level":31},"b22","Where it won&#39;t save you","Where it won't save you",{"id":213,"html":214,"type":139},"b23","\u003Cp>This catches \u003Cem>missing\u003C\u002Fem> cases, not \u003Cem>wrong\u003C\u002Fem> ones. If you handle \u003Ccode>&quot;refunded&quot;\u003C\u002Fcode> by copy-pasting the \u003Ccode>&quot;paid&quot;\u003C\u002Fcode> branch, the compiler has nothing to say — that&#39;s a logic bug, not an exhaustiveness bug, and no type system catches those for free.\u003C\u002Fp>",{"id":216,"html":217,"type":139},"b24","\u003Cp>It also needs an honest \u003Ccode>default\u003C\u002Fcode> (or a final \u003Ccode>else\u003C\u002Fcode>) with nothing after it that would make the branch unreachable another way — wrap the call in a function typed to return the right thing, as above, rather than leaving it as a bare statement the compiler could route around. And it only protects the functions you&#39;ve actually wired this way; it doesn&#39;t retroactively audit a codebase. The value compounds the way tests do — add it to every switch over a union that models real states (order status, payment status, permission level, wizard step), and the moment someone extends that union, the compiler goes and finds every place that forgot, for you, before a reviewer has to.\u003C\u002Fp>",{"id":219,"html":220,"type":139},"b25","\u003C!-- playground:start -->",{"id":222,"html":223,"text":223,"type":149,"level":31},"b26","🎮 Try it yourself",{"id":225,"html":226,"type":139},"b27","\u003Cp>\u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-exhaustiveness-checking-never\u002Fplayground\">▶️ Open the interactive playground →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":228,"html":229,"type":139},"b28","\u003Cp>\u003Cem>Runs right in your browser — poke at it and watch the concept react live.\u003C\u002Fem>\u003C\u002Fp>",{"id":231,"html":232,"type":139},"b29","\u003C!-- playground:end -->",{"id":234,"html":235,"text":235,"type":149,"level":31},"b30","The payoff",{"id":237,"html":238,"type":139},"b31","\u003Cp>Go check whatever \u003Ccode>OrderStatus\u003C\u002Fcode>-shaped type your codebase already has — a job status, a subscription tier, a form step — and find the switch statements over it. If none of them end in a call to a \u003Ccode>never\u003C\u002Fcode>-typed function, the next person to extend that union is one keystroke away from shipping the same quiet gap &quot;refunded&quot; fell into above. One function, reused everywhere: that&#39;s the whole fix.\u003C\u002Fp>",{"id":240,"html":241,"type":139},"b32","\u003C!-- quiz:start -->",{"id":243,"html":244,"text":244,"type":149,"level":31},"b33","🧠 Test yourself",{"id":246,"html":247,"type":139},"b34","\u003Cp>Think it clicked? \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-exhaustiveness-checking-never\u002Fquiz\">Take the 8-question quiz →\u003C\u002Fa>\u003C\u002Fstrong>\u003C\u002Fp>",{"id":249,"html":250,"type":139},"b35","\u003Cp>\u003Cem>Instant feedback, a hint on every question, and an explanation for each answer — right or wrong.\u003C\u002Fem>\u003C\u002Fp>",{"id":252,"html":253,"type":139},"b36","\u003C!-- quiz:end -->",{"id":255,"html":256,"type":139},"b37","\u003Cp>Has a missing \u003Ccode>switch\u003C\u002Fcode> case ever gotten past your reviewers and into production? What did it look like when you finally found it?\u003C\u002Fp>",{"id":258,"html":259,"type":139},"b38","\u003C!-- related:start -->",{"id":261,"html":262,"text":262,"type":149,"level":31},"b39","📚 Read next",{"id":264,"type":265,"items":266,"ordered":18},"b40","list",[267,268,269],"\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-as-const-assertions\">My Reducer&#39;s Switch Stopped Being Exhaustive. \u003Ccode>as const\u003C\u002Fcode> Fixed It.\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-satisfies-operator\">Your TypeScript config objects are losing type information. \u003Ccode>satisfies\u003C\u002Fcode> fixes it.\u003C\u002Fa>","\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fintl-numberformat-currency-formatting\">Stop Formatting Currency With Regex. \u003Ccode>Intl.NumberFormat\u003C\u002Fcode> Does It.\u003C\u002Fa>",{"id":271,"html":272,"type":139},"b41","\u003C!-- related:end -->",{"id":274,"type":275},"b42","divider",{"id":277,"html":278,"type":139},"b43","\u003Cp>🚀 \u003Cstrong>Want more like this?\u003C\u002Fstrong> Every guide, playground, and quiz lives on \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">bestpractic.org\u003C\u002Fa>\u003C\u002Fstrong> — open it and \u003Cstrong>\u003Ca href=\"https:\u002F\u002Fbestpractic.org\u002F\">sign up free\u003C\u002Fa>\u003C\u002Fstrong> so the next one finds you.\u003C\u002Fp>",{"id":280,"html":281,"type":139},"b44","\u003Cp>\u003Cem>Thanks for reading! Let&#39;s stay connected:\u003C\u002Fem>\u003C\u002Fp>",{"id":283,"type":265,"items":284,"ordered":18},"b45",[285,286,287],"⭐ \u003Cstrong>GitHub\u003C\u002Fstrong> — follow me and star the projects: \u003Ca href=\"https:\u002F\u002Fgithub.com\u002Fparsajiravand\">github.com\u002Fparsajiravand\u003C\u002Fa>","💬 \u003Cstrong>Discord\u003C\u002Fstrong> — join the frontend best-practices community: \u003Ca href=\"https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ\">discord.gg\u002Fd9KRhuAwQ\u003C\u002Fa>","📸 \u003Cstrong>Instagram\u003C\u002Fstrong> — frontend best practices, daily: \u003Ca href=\"https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F\">@bestpractice___\u003C\u002Fa>","Someone on your team adds `\"refunded\"` to the `OrderStatus` union. Three files use that type. Two of them get updated. The third — the one that renders the status badge on the order page — doesn't.\n\nIt compiles. It ships. A refunded order sits on a customer's dashboard labeled \"Processing\" for two weeks, because the `switch` that renders the badge has no idea `\"refunded\"` exists, falls through to nothing, and renders an empty string.\n\nNobody wrote a bug. Someone just didn't update every place that needed updating — which is the normal, forgivable thing that happens on every team, every week. The question is whether your type system notices.\n\n## The fix everyone reaches for first\n\nThe instinctive move is a `default` case:\n\n```typescript\ntype OrderStatus = \"pending\" | \"paid\" | \"shipped\" | \"delivered\";\n\nfunction badgeText(status: OrderStatus): string {\n  switch (status) {\n    case \"pending\":\n      return \"Processing\";\n    case \"paid\":\n      return \"Payment received\";\n    case \"shipped\":\n      return \"On the way\";\n    case \"delivered\":\n      return \"Delivered\";\n    default:\n      return \"Processing\"; \u002F\u002F \"it has to be something\"\n  }\n}\n```\n\nThis feels safe. It isn't. Add `\"refunded\"` to the union tomorrow, and this function keeps compiling, keeps running, and keeps quietly mislabeling refunded orders as \"Processing\" — the exact bug from the top of this post, except now it's load-bearing, because the `default` case was *designed* to swallow anything unexpected.\n\nA `console.warn` in the default branch helps you find out *after* it's in production, if anyone's watching logs. What you actually want is to find out before you hit \"merge.\"\n\n## What you want instead: make the gap a compile error\n\nTypeScript already tracks, branch by branch, which members of a union a `switch` has ruled out. Inside the `default` case of a fully-handled switch, the type of `status` isn't `OrderStatus` anymore — it's narrowed down to whatever's left over. If every case was handled, what's left over is nothing at all: the `never` type, TypeScript's name for \"a value that cannot exist.\"\n\nThat's the lever. Write a function that only accepts `never`, and call it from the `default` branch:\n\n```typescript\nfunction assertUnreachable(x: never): never {\n  throw new Error(`Unhandled case: ${JSON.stringify(x)}`);\n}\n\nfunction badgeText(status: OrderStatus): string {\n  switch (status) {\n    case \"pending\":\n      return \"Processing\";\n    case \"paid\":\n      return \"Payment received\";\n    case \"shipped\":\n      return \"On the way\";\n    case \"delivered\":\n      return \"Delivered\";\n    default:\n      return assertUnreachable(status);\n  }\n}\n```\n\nRight now this compiles cleanly, because TypeScript has proven `status` really is `never` by the time it reaches `default` — every other member of the union got its own case above.\n\nNow add `\"refunded\"` to `OrderStatus` and change nothing else:\n\n```typescript\ntype OrderStatus = \"pending\" | \"paid\" | \"shipped\" | \"delivered\" | \"refunded\";\n```\n\nThe `badgeText` function no longer compiles. TypeScript narrows `status` in the `default` branch to `\"refunded\"` — one real, leftover case — and `\"refunded\"` is not assignable to the parameter type `never`. The error points at the exact line, in the exact file, that forgot to handle the new status. Not a runtime log line three weeks from now. A red squiggle before you push.\n\n## Why `never` is the right tool for this\n\n`never` is TypeScript's type for \"this code path cannot be reached\" — functions that always throw, infinite loops, and branches a union's structure has already ruled out. Assigning a value to a `never`-typed parameter is only legal if TypeScript can prove no value is left to assign. That's precisely what \"the switch handled every case\" means. You're not writing a special exhaustiveness feature; you're pointing a general-purpose type at a question it's already equipped to answer.\n\nIt composes the same way with `if`\u002F`else if` chains — narrowing works the same way there:\n\n```typescript\nfunction badgeTextIf(status: OrderStatus): string {\n  if (status === \"pending\") return \"Processing\";\n  else if (status === \"paid\") return \"Payment received\";\n  else if (status === \"shipped\") return \"On the way\";\n  else if (status === \"delivered\") return \"Delivered\";\n  else return assertUnreachable(status);\n}\n```\n\nSame guarantee, same failure mode when you add `\"refunded\"` without touching this function.\n\n## Where it won't save you\n\nThis catches *missing* cases, not *wrong* ones. If you handle `\"refunded\"` by copy-pasting the `\"paid\"` branch, the compiler has nothing to say — that's a logic bug, not an exhaustiveness bug, and no type system catches those for free.\n\nIt also needs an honest `default` (or a final `else`) with nothing after it that would make the branch unreachable another way — wrap the call in a function typed to return the right thing, as above, rather than leaving it as a bare statement the compiler could route around. And it only protects the functions you've actually wired this way; it doesn't retroactively audit a codebase. The value compounds the way tests do — add it to every switch over a union that models real states (order status, payment status, permission level, wizard step), and the moment someone extends that union, the compiler goes and finds every place that forgot, for you, before a reviewer has to.\n\n\u003C!-- playground:start -->\n\n## 🎮 Try it yourself\n\n**[▶️ Open the interactive playground →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-exhaustiveness-checking-never\u002Fplayground)**\n\n_Runs right in your browser — poke at it and watch the concept react live._\n\n\u003C!-- playground:end -->\n\n## The payoff\n\nGo check whatever `OrderStatus`-shaped type your codebase already has — a job status, a subscription tier, a form step — and find the switch statements over it. If none of them end in a call to a `never`-typed function, the next person to extend that union is one keystroke away from shipping the same quiet gap \"refunded\" fell into above. One function, reused everywhere: that's the whole fix.\n\n\u003C!-- quiz:start -->\n\n## 🧠 Test yourself\n\nThink it clicked? **[Take the 8-question quiz →](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-exhaustiveness-checking-never\u002Fquiz)**\n\n_Instant feedback, a hint on every question, and an explanation for each answer — right or wrong._\n\n\u003C!-- quiz:end -->\n\nHas a missing `switch` case ever gotten past your reviewers and into production? What did it look like when you finally found it?\n\n\u003C!-- related:start -->\n\n## 📚 Read next\n\n- [My Reducer's Switch Stopped Being Exhaustive. `as const` Fixed It.](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-as-const-assertions)\n- [Your TypeScript config objects are losing type information. `satisfies` fixes it.](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-satisfies-operator)\n- [Stop Formatting Currency With Regex. `Intl.NumberFormat` Does It.](https:\u002F\u002Fbestpractic.org\u002Fblog\u002Fintl-numberformat-currency-formatting)\n\n\u003C!-- related:end -->\n\n---\n\n🚀 **Want more like this?** Every guide, playground, and quiz lives on **[bestpractic.org](https:\u002F\u002Fbestpractic.org\u002F)** — open it and **[sign up free](https:\u002F\u002Fbestpractic.org\u002F)** so the next one finds you.\n\n*Thanks for reading! Let's stay connected:*\n\n- ⭐ **GitHub** — follow me and star the projects: [github.com\u002Fparsajiravand](https:\u002F\u002Fgithub.com\u002Fparsajiravand)\n- 💬 **Discord** — join the frontend best-practices community: [discord.gg\u002Fd9KRhuAwQ](https:\u002F\u002Fdiscord.gg\u002Fd9KRhuAwQ)\n- 📸 **Instagram** — frontend best practices, daily: [@bestpractice___](https:\u002F\u002Fwww.instagram.com\u002Fbestpractice___\u002F)",{"title":111,"canonical":290,"description":112},"https:\u002F\u002Fbestpractic.org\u002Fblog\u002Ftypescript-exhaustiveness-checking-never","01a1df1b-2879-726c-b86f-6c02396ce30f",{"id":293,"locked":18},"01a1df1b-289a-73f3-adc6-d0b61c12944e",[295],{"id":45,"slug":46,"title":48,"_count":296},{"questions":51},[298],{"locale":13,"slug":46},{"id":45,"slug":46,"title":48,"_count":300,"questionCount":51},{"questions":51},[]]