beraliv

If statement type in TypeScript

Example of If use
Example of If use

Eighth challenge is If

It is common to use conditional statement to get either of branches. Like conditional, or ternary, operator in JavaScript.

Checking if the value is true

Conditional types are what we really need:

If solution
If solution

Also I added C extends boolean so we are always sure that we only have true and false ⭐️

If you interested in test cases, please have a look at Playground

typescript

Comments

Alexey Berezin profile image

Written by Alexey Berezin who loves London 🏴󠁧󠁢󠁥󠁮󠁧󠁿, players ⏯ and TypeScript 🦺 Follow me on Twitter