Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

BernardoBF4's avatar

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?

0 likes
0 replies

Please or to participate in this conversation.