Skip to content

Instantly share code, notes, and snippets.

@LuxXx
Created August 14, 2023 22:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LuxXx/11b2b3f5cd01f8abeca58614f11e638c to your computer and use it in GitHub Desktop.
Save LuxXx/11b2b3f5cd01f8abeca58614f11e638c to your computer and use it in GitHub Desktop.
exhausting switch
type Book = "dune" | "snowcrash" | "dune2"
const b: Book = Math.random() > 0.5 ? "dune" : "snowcrash"
function f() {
switch (b) {
case "dune":
return 0
case "snowcrash":
return 0
case "dune2":
return 0
default:
b satisfies never
return 0
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment