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?

1
  • 1
    You need to do this or the equivalent. Commented Mar 3, 2023 at 15:09

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.