TypeScript: Conditional Types Explained

Learn what conditionals are and how they are used in TypeScript

Ross Bulat
10 min readMar 5, 2021

--

Conditionals in TypeScript, also introduced in the TypeScript handbook, allow us to deterministically define types depending on what parameterised types consist of. The general basic rule is:

type ConditionalType = T extends U ? X : Y

--

--

Ross Bulat

Programmer and Author. @ Parity Technologies, JKRB Investments