beginner45 minby DevFox

Discriminated unions

Give every shape of a union the same property with its own word, like a label on a parcel that says what is inside. Check that word with three equals signs or a switch, see which shape TypeScript gives the value on every branch, tell a trip from a day off, and turn TaskKit’s commands into such a union.

  • TypeScript
  • Fundamentals
Discriminated unions. Read this lesson at .