2

I have an array of objects:

const arr = [{
  value: 'value1',
  key: 'key1'
}, {
  value: 'value2',
  key: 'key2'
}]

What I want to achieve is to get an union type having the values of value key.

type Values = 'value1' | 'value2';

How can I define the type to generate it automatically from the array of objects?

sunpietro
  • 2,059
  • 4
  • 24
  • 42

0 Answers0