Stop 07 · TypeScriptTopics · 5/12

Union

Part of the Frontend Developer Roadmap

In short

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

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

More topics at this stop

Stuck on this topic? Ask an Insider

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

Download
InsideEdge