Conditional types in TypeScript

A conditional type in TypeScript is an if-then-else expression: Its result is either one of two branches – which one depends on a condition. That is especially useful in generic types. Conditional types are also an essential tool for working with union…


This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer

A conditional type in TypeScript is an if-then-else expression: Its result is either one of two branches – which one depends on a condition. That is especially useful in generic types. Conditional types are also an essential tool for working with union types because they let us “loop” over them. Read on if you want to know how all of that works.


This content originally appeared on 2ality – JavaScript and more and was authored by Dr. Axel Rauschmayer


Print Share Comment Cite Upload Translate Updates
APA

Dr. Axel Rauschmayer | Sciencx (2025-02-15T00:00:00+00:00) Conditional types in TypeScript. Retrieved from https://www.scien.cx/2025/02/15/conditional-types-in-typescript-3/

MLA
" » Conditional types in TypeScript." Dr. Axel Rauschmayer | Sciencx - Saturday February 15, 2025, https://www.scien.cx/2025/02/15/conditional-types-in-typescript-3/
HARVARD
Dr. Axel Rauschmayer | Sciencx Saturday February 15, 2025 » Conditional types in TypeScript., viewed ,<https://www.scien.cx/2025/02/15/conditional-types-in-typescript-3/>
VANCOUVER
Dr. Axel Rauschmayer | Sciencx - » Conditional types in TypeScript. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/02/15/conditional-types-in-typescript-3/
CHICAGO
" » Conditional types in TypeScript." Dr. Axel Rauschmayer | Sciencx - Accessed . https://www.scien.cx/2025/02/15/conditional-types-in-typescript-3/
IEEE
" » Conditional types in TypeScript." Dr. Axel Rauschmayer | Sciencx [Online]. Available: https://www.scien.cx/2025/02/15/conditional-types-in-typescript-3/. [Accessed: ]
rf:citation
» Conditional types in TypeScript | Dr. Axel Rauschmayer | Sciencx | https://www.scien.cx/2025/02/15/conditional-types-in-typescript-3/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.