#Object and Array Props
10 messages · Page 1 of 1 (latest)
export interface Props {
image: object
caption?: string
video?: string
}```
^ Take this example where I have an image object but would like to define that it has src and alt keys that are both strings.
You can do something like this ```ts
export interface Props {
image: {src:string, alt:string}
caption?: string
video?: string
}
Thank you!
I can do something similar with arrays but wrap the image object in array brackets?
Like an array of image objects?
You can do {src:string, alt:string}[] or Array<{src:string, alt:string}>