// a union of string literals restricts the allowed values
type Direction = "north" | "south" | "east" | "west";
function step(d: Direction): [number, number] {
switch (d) {
case "north":
return [0, 1];
case "south":
return [0, -1];
case "east":
return [1, 0];
case "west":
return [-1, 0];
}
}
console.log(step("east"));a union of literals as an exhaustive input