When working with one of multiple interfaces, I encounter an issue in Vue where it claims the property does not exist.
export interface Link {
to: string
text?: string;
}
export interface Text {
text: string;
}
export interface Html {
html: string
}
export type DataItem = Text | Link | Html;
Within my Vue loop over data items, attempting to access a property triggers an error:
<template
v-for="(dataItem, index) in item.data" :key="index"
>
<p if="dataItem?.text" :class="itemClasses">
{{ dataItem.text }}
</p>
The error message specifically states
Property 'text' does not exist on type 'DataItem'.