I am working with a generated interface that looks like this:
export interface StaticPageLeftMenuV1 {
id: string
status: 'draft' | 'published'
environments: ('dev' | 'staging' | 'production')[]
created_by?: string | User
last_modified_by?: string | User
list?: {
header?: string
items?: {
relation?: {
value: string | StaticPageV1
relationTo: 'static-page-v1'
}
custom_link_text?: string
custom_link_url?: string
custom_link_color?: string
id?: string
}[]
id?: string
}[]
}
I am wondering how I can declare the type of an item, as seen in obj.list[0].items[0]
To get the list easily, you can use:
type List = StaticPageLeftMenuV1['list']
This will give you an array, but I am struggling to figure out how to obtain the type of the object.
The following approach doesn't seem to work:
type Item = StaticPageLeftMenuV1['list'][0]['items'][0]