Type Systems: Reachability and Exhaustiveness analysis explained

Reachability

function method(value: "A") {
if (value === "B") {
// unreachable
}
}

Exhaustiveness

function method(value: "A" | "B") {
switch (value) {
case "A" : // value is A...
case "B" : // value is B...
default : // unreachable
}
}

 by the author.

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Jamie Kyle

Jamie Kyle

More from Medium

Exploring Design Patterns — Composite Pattern (Basic Arithmetic Expression)

12 steps on writing better code

HTTP1 VS HTTP2

Design and Implementation

System context for the weather station