Sobes.tech
Junior — Senior

Conditional types in TypeScript: implementing generic conditions

livecode

Task condition

Implement a conditional type in TypeScript that chooses one of two options based on a boolean parameter.

type TrueResult = If<true, 'a', 'b'>  // expected to be 'a'
type FalseResult = If<false, 'a', 'b'> // expected to be 'b'