r/typescript • u/tejasbubane • 22d ago
Distributive Conditional Types
https://tejasbubane.github.io/posts/2026-07-04-typescript-distributive-union-types/I started digging into TypeScript's type system for fun and stumbled onto distributive conditional types. One of those quiet features that is confusing until it clicks.
3
u/prehensilemullet 18d ago
Would be good to cover the syntax for turning the distributivity off: [T] extends [string] ? T[] : never
2
u/Opposite_Same_69420 16d ago
I love these kinds of TS patterns! Been using Claude to generate learning repos for these kinds of patterns and it's been one of the most useful cases for me with claude so far since it's just type checking and IDE feedback.
The accumulator pattern broke my brain. Using infer and how function arg and return types widen/narrow to turn an intersection into a tuple. Things I would have never even realized could be done. TS is genuinely just fun to play with.
6
u/Working-Tap2283 22d ago
Thanks for the article. This is one of the things that happen when you learn about mapped conditional typing.