1

I need an array of all possible values of two types defined in two different third party libs. That part is simple, but how can I ensure that the array contains all values? I hope this is possibly by adapting the type WithLegs.

// Out of my control as defined in third party lib
type WithFourLegs = 'Cat' | 'Cow' | 'Dog';
type WithTwoLegs = 'Human' | 'Ostrich';

// In my control
type WithLegs = WithFourLegs | WithTwoLegs;

// Should fail because 'Dog' and 'Ostrich' are missing
const allWithLegs: WithLegs[] = [ 'Human', 'Cow', 'Cat' ];
Sebastian Barth
  • 4,079
  • 7
  • 40
  • 59

0 Answers0