Menu

1 / 2

Distributive Conditional Types: The Gateway to Advanced TS

DEV Community·Gabriel Anhaia·6 months ago
#5zoTmELR
#typescript#programming#webdev#type#union
Reading 0:00
15s threshold

Book: The TypeScript Type System

Also by me: The TypeScript Library — the 5-book collection

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

You open a fresh playground tab. You type type R = Exclude<"a" | "b" | "c", "b"> . The tooltip says "a" | "c" . You nod, paste it into the codebase, and move on. You have used Exclude for years and never once written it.

Ask yourself how Exclude works and the answer is some shape of "it removes things from a union." That answers what Exclude does. It does not answer how. The how is a single rule about conditional types the tooltip never shows you. Once you see the rule, half of the standard library starts looking ordinary. The conditional types chapter of the handbook reads like a different language.

The rule is small. The consequences are large.

Conditional Types Are the Boring Part

Start at the floor.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.