Having an issue with Vue3's script setup syntax where a strange ts error occurs when trying to assign a variable as a prop value.
I have defined a type Stuff: 'item' | 'box' | 'area'
and using it as the PropType for my prop kind
in the SearchBar component.
const props = defineProps({
kind: { type: String as PropType<Stuff> },
placeholder: String,
})
But when I pass a variable with the value of 'item'
to that prop in the component, I encounter this error:
https://i.sstatic.net/7KF3G.png
Type 'string' is not assignable to type 'Stuff | undefined'.
I've noticed similar errors involving the use of string
and String
before, seemingly related to casing conventions between TS and Vue.
If anyone has any tips or workarounds, your input would be greatly appreciated!