interface Filter {
id: string;
name: string;
}
type Filters = Filter[];
const filters = [{ id: 'f1', name: 'f1name'}, { id: 'f2', name: 'f2name'}]
interface State { ... }
const state = {
f1: any,
f2: any
}
I am looking to define the type of state
. My goal is to create a type called State
that represents an object with the same number of properties as the objects in filters
, and I want to limit the type of each property to be the union of the types of the id
property from filters
.
In the scenario given above, the type of state
is State
, which means it is "an object containing keys 'f1' | 'f2'
with values of type any
.