QuizIntermediate
Narrowing Literal and Union Types
Learn how comparing to a literal narrows a union of string literals.
Given `dir: "left" | "right" | "up"`, inside `if (dir === "left") { ... }`, what type is `dir`?
Learn how comparing to a literal narrows a union of string literals.
Given `dir: "left" | "right" | "up"`, inside `if (dir === "left") { ... }`, what type is `dir`?