Created
August 14, 2023 22:25
-
-
Save LuxXx/11b2b3f5cd01f8abeca58614f11e638c to your computer and use it in GitHub Desktop.
exhausting switch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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