Check is value is member of Union type
“Array first” approach
https://dev.to/hansott/how-to-check-if-string-is-member-of-union-type-1j4m
1 | const ALL_SUITS = ['hearts', 'diamonds', 'spades', 'clubs'] as const |
Type guard function
1 | function isSuit(value: string): value is Suit { |