Subscribe on changes!

An error is reported on the external TS interface

avatar
Mar 29th 2022

Version

3.2.16

Reproduction link

stackblitz.com

Steps to reproduce

import {ForgetProps} from "@/types/login";
const props = withDefaults(defineProps<ForgetProps>(), {
    visible: false
})

What is expected?

Child component:

import {ForgetProps} from "@/types/login";
const props = withDefaults(defineProps<ForgetProps>(), {
    visible: false
})

ForgetProps:

export interface ForgetProps {
    visible: boolean;
    type: boolean;
}

I expect him to be right!

but, However, it is correct to use this in the component and will not report an error!

interface Props {
    visible: boolean
}

const props = withDefaults(defineProps<Props>(), {
    visible: false
})

What is actually happening?

It is wrong because: type argument passed to defineProps() must be a literal type, or a reference to an interface or literal type.


I don't know if it's because the syntax is incorrect or this syntax is not supported

avatar
Mar 29th 2022

Using imported interfaces as a generic argument for defineProps() is not supported yet. See #4294