0

I have an interface

export interface MyRange {
  min: number
  max: number
}

inside a vue3 component I have a type

type SliderType = number | MyRange

and I want a property of the component, which would be the v-model, to be number or MyRange so I set

props: {        
    modelValue: {
        type: Object as PropType<SliderType>,
        required: true
    }
}

in setup I init my v-model var

const modelValueCopy: Ref<SliderType> = ref(props.modelValue)

It works but I got the ts2322 error, that SliderType can't be assigned to number | null | undefined, and Range can't be assigned to number

any idea how to fix this?

I've tried this

props: {        
    modelValue: {
        type: number | MyRange,
        required: true
    }
}

but it doesn't work

c.m.
  • 320
  • 2
  • 9
  • Does this answer your question? [How to add multiple data types for VueJs Props?](https://stackoverflow.com/questions/53608244/how-to-add-multiple-data-types-for-vuejs-props) – illeb Oct 10 '22 at 09:35
  • No, this doesn't work – c.m. Oct 10 '22 at 09:45

0 Answers0