beginner35 minby DevFox

Narrowing with typeof, equality, and truthiness

Ask a value which member of its union it holds, like a till that looks at cash or card before it opens the drawer. Check it with typeof, with three equals signs or as its own condition, see which type TypeScript gives it inside the check and in the else, add up a week of minutes, and avoid the check that quietly loses a zero.

  • TypeScript
  • Fundamentals
Narrowing with `typeof`, equality, and truthiness. Read this lesson at .