Phase 7 · TypeScript

Topics

Union

Part of the Frontend Developer Roadmap.

Summary

A type formed by combining multiple types with `|`, meaning a value can be one of several possible types (e.g. `string | number`).

How to Learn This

  • 1Model a function parameter that accepts either a `string` or `number`.
  • 2Practice narrowing a union type using `typeof` or `in` checks.
  • 3Model a set of related states as a union of object shapes — a 'discriminated union'.
InsideEdge

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — free on the InsideEdge app.

Download
InsideEdge