Given the following generic
type WheneverPossible<T extends "boy" | "girl"> = ...
I want to check conditionally on this generic like the following:
type WheneverPossible<T extends "boy" | "girl"> = T === "boy" ? { numOfBalls: number } : { numOfDolls: number }
Is there a possibility to do something like this in Typescript?
>Solution :
It is possible just use the extends keyword
type WheneverPossible<T extends "boy" | "girl"> = T extends "boy"
? { numOfBalls: number }
: { numOfDolls: number }