---
source: https://iinventedlight.com/library/notes/typescript-discriminated-unions.md
title: "TypeScript discriminated unions narrow a value by a shared kind field"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (TypeScript Handbook); CC-BY-4.0 (microsoft/TypeScript-Website (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: TypeScript Handbook, Narrowing (Discriminated unions), CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE); microsoft/TypeScript-Website (GitHub), Narrowing.md (TypeScript-Website), CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: TypeScript discriminated unions"
tags: [typescript, discriminated-unions, narrowing, kind]
client: Librarian
sources:
  - id: S1
    title: "Narrowing (Discriminated unions)"
    publisher: TypeScript Handbook
    url: https://www.typescriptlang.org/docs/handbook/2/narrowing.html
    accessed: 2026-11-16
    license: "CC-BY-4.0"
  - id: S2
    title: "Narrowing.md (TypeScript-Website)"
    publisher: microsoft/TypeScript-Website (GitHub)
    url: https://github.com/microsoft/TypeScript-Website/blob/v2/packages/documentation/copy/en/handbook-v2/Narrowing.md
    accessed: 2026-11-16
    license: "CC-BY-4.0"
---
# TypeScript discriminated unions narrow a value by a shared kind field
**Answer:** Most earlier handbook examples have focused around narrowing single variables with simple types like `string`, `boolean`, and `number`. Discriminated unions cover more complex structures.

## The shape example

Imagine encoding shapes like circles and squares. Circles keep track of their radiuses. Squares store a side length in the example. We'll use a field called `kind` to tell which shape is in use.

## See also

- [typescript-narrowing](https://iinventedlight.com/library/notes/typescript-narrowing/)
- [typescript-satisfies-operator](https://iinventedlight.com/library/notes/typescript-satisfies-operator/)

## Claims

- id: C1
  claim: The handbook has a Discriminated unions section.
  source: S1
  evidence: "Discriminated unions"

- id: C2
  claim: A kind field can tell circle and square variants apart.
  source: S2
  evidence: "We'll use a field called `kind` to tell which"

- id: C3
  claim: Circles keep track of their radiuses in the example.
  source: S2
  evidence: "Circles keep track of their radiuses and squares keep track of their side lengths."

- id: C4
  claim: Most earlier narrowing examples use simple types such as string.
  source: S2
  evidence: "narrowing single variables with simple types like `string`"

## Sources

- [S1] Narrowing (Discriminated unions). TypeScript Handbook. https://www.typescriptlang.org/docs/handbook/2/narrowing.html . License: CC-BY-4.0. Accessed 2026-11-16.

- [S2] Narrowing.md (TypeScript-Website). microsoft/TypeScript-Website (GitHub). https://github.com/microsoft/TypeScript-Website/blob/v2/packages/documentation/copy/en/handbook-v2/Narrowing.md . License: CC-BY-4.0. Accessed 2026-11-16.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: TypeScript Handbook, Narrowing (Discriminated unions), CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE); microsoft/TypeScript-Website (GitHub), Narrowing.md (TypeScript-Website), CC-BY-4.0 (https://raw.githubusercontent.com/microsoft/TypeScript-Website/v2/LICENSE). Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
