Concept
With a never-typed default branch, the compiler errors when a new union member is added and a switch does not handle it. It turns "did I update every switch?" into a build error.
The tutor works through these with you, in conversation and code. A session ends when you have shown them, not when a video does.
A few lines that show Exhaustiveness checks doing its job.
type Status = "idle" | "loading" | "done";
function label(status: Status): string {
switch (status) {
case "idle": return "Ready";
case "loading": return "Working";
case "done": return "Finished";
default: {
const unreachable: never = status; // errors if a case is missing
return unreachable;
}
}
}Writing default: return "Unknown". It compiles forever, so when "failed" is added to the union the function quietly returns the wrong label and nothing tells you.
Your roadmap puts these before Exhaustiveness checks, unless you already know them.
Once a session shows you understand Exhaustiveness checks, it comes back for review. Each review takes a minute and tells the memory model how well you still know it.