Skip to content
Quiz · Narrowing · lesson 10 of 12

Quiz — a forgotten case

What does tsc report for this file?

TypeScript
type Pay = "card" | "cash" | "crypto";
function payName(p: Pay): string {
    switch (p) {
        case "card":
            return "Card";
        case "cash":
            return "Cash";
        default:
            const rest: never = p;
            return rest;
    }
}