Aug 24, 2023
0
Level 4
How to add TS typing to Vue prop
I have a Vue component wich receives a prop tabs. This prop is supposed to follow this pattern:
[{
id: string
title: string
color: `#${string}`
},{
id: string
title: string
color: `#${string}`
}]
I am using Laravel + Vite + Vue 2, and because Vite allows me to use Typescript, I'd like to have my tabs prop typed. I know this is possible with JS types, but here I want my custom type above as the type for this prop. I have searched a bit already and didn't find how to do this, unless I start using Vue 3 (wich won't happen in the current state of my project). So, anyones knows if this is possible, and, if it is, how to do it?
Please or to participate in this conversation.