Skip to content

No overload matches this call. While declaring Props with Proptype<T> (TypeScript) #4554

@Pentadome

Description

@Pentadome

Version

3.2.11

Reproduction link

sfc.vuejs.org/

Steps to reproduce

interface Option {
    value: unknown;
    text: string;
}

const optionsProptype: PropType<string[]> | PropType<number[]> | PropType<Option[]> = Array;
// const selectedProptype = [String, Number, Object]; <-- this works
// const selectedProptype = [String, Number, Object] as const; <-- Doesn't work but not a big deal. Wanted to mention it anyways.
const selectedProptype = [String, Number, Object as PropType<Option>];

export default defineComponent({
    props: {
        options: {
            type: optionsProptype,
            required: true,
        },
        modelValue: { // <---- ERROR: No overload matches this call. The last overload gave the following error. ts(2769)
            type: selectedProptype,
            required: true,
        },
    },
});

What is expected?

No error

What is actually happening?

ERROR: No overload matches this call. The last overload gave the following error. ts(2769)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions