1.

What are conditional types? How do you create them?

Answer»

A conditional type ALLOWS you to DYNAMICALLY select one of two POSSIBLE types based on a CONDITION. The condition is expressed as a type relationship test.

C extends B ? TypeX : TypeY

Here, if type C extends B, the value of the above type is TypeX. Otherwise, it is TypeY.



Discussion

No Comment Found