0๐
โ
Use a function expression for that prop type:
const Component = defineComponent({
props: {
book: { ๐
type: [String, () => Object as PropType<Book>]
}
},
mounted() {
const isBook = (obj: any): obj is Book => 'title' in obj // eslint-disable-line @typescript-eslint/no-explicit-any
if (isBook(this.book)) {
console.log(this.book.title)
}
}
})
Source:stackexchange.com