If statement type in TypeScript
14 Apr 2021
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:
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