I have a simple prop in my Vue.js component in which I want to pass either a boolean or an array.
The problem is that when I do:
props: {
checked: {
type: [Boolean, Array],
default: false,
},
},
I will have to face the problems an unknow[] array will give me.
And if I do something like this:
props: {
checked: {
type: [Boolean, Array as PropType<string[] | number[]>],
default: false,
},
},
It will completely break my component. What am I doing wrong?
Thank you in advance for any help my bros.
type: Object as PropType<boolean | string[] | number[]>. That downside to that is you lose runtime prop validation ofBooleanduring dev, but the TypeScript compiler errors should help.