TYPESCRIPTChapter 4 · TS Expert
Conditional Types
Conditional Types let you select types dynamically by checking if type T extends type U. They work like ternary conditional operators (T extends U ? X : Y).
Worked example
How it reads
- T extends string tests if the generic type extends a string
- ? 'yes' : 'no' resolves to different types depending on the check

Cloud tip: Conditional types are the core of advanced type manipulation and libraries.


