This snippet defines the variable type
type imageTags: string | number | {
tag_type: string;
tag_name: string;
tag_id: number;
photo_id: number;
confidence: number;
}[]
Here is how I attempt to access its properties.
if (imageTags.length > 0) {
return imageTags[0].tag_name === image_type;
}
The variable can be a string, number, or array. So why am I encountering the error message Property 'length' does not exist on type 'string | number | { tag_type: string; tag_name: string; tag_id: number; photo_id: number; confidence: number; }[]'. Property 'length' does not exist on type 'number'.ts(2339)?