I have an object with both keys and values as strings.
const obj: {[key: string]: string} = {first: 'a', second: 'b'}
I would like to declare that object values must be one of array values:
Example:
const arr: string = ['a', 'b', 'c']
const b: {[key: string]: string/*valueOf(arr)*/} = {
first: 'a', // to be legal
second: 'f', // to throw an error
}
Searched for a similar case, but in my case arr
is an array instead of a type.
How can I declare that right?