-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing base props in generic component #8604
Comments
It's a language-tools issue. |
It's in |
Hmmm, maybe u r right! 😂 |
There seems to be a problem with the type returned by the defineComponent function. The example is as follows: const TestCom = defineComponent((props) => {
// ...
}, {
props: {
name: {
type: String,
required: true,
},
size: {
type: Number,
default: 16,
},
}
}); The inferred type of TestCom is: const TestCom: (props: {
name: string;
size: number;
} & {}) => any The props part type is:
The props type is correct, the TestCom type is wrong, the TestCom type should be: const TestCom: (props: {
name: string;
size?: number;
} & {}) => any defineComponent function signature export declare function defineComponent<Props extends Record<string, any>, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}>(setup: (props: Props, ctx: SetupContext<E, S>) => RenderFunction | Promise<RenderFunction>, options?: Pick<ComponentOptions, 'name' | 'inheritAttrs'> & {
props?: (keyof Props)[];
emits?: E | EE[];
slots?: S;
}): (props: Props & EmitsToProps<E>) => any;
export declare function defineComponent<Props extends Record<string, any>, E extends EmitsOptions = {}, EE extends string = string, S extends SlotsType = {}>(setup: (props: Props, ctx: SetupContext<E, S>) => RenderFunction | Promise<RenderFunction>, options?: Pick<ComponentOptions, 'name' | 'inheritAttrs'> & {
props?: ComponentObjectPropsOptions<Props>;
emits?: E | EE[];
slots?: S;
}): (props: Props & EmitsToProps<E>) => any; There seems to be no distinction between internal and external types of components |
Vue version
3.3.4
Link to minimal reproduction
https://github.com/s-montigny-desautels/vue3.3-issues
Steps to reproduce
Look for the error in file
BugTSXClassUnknownProperty.tsx
and fileBugTSXClassUnknownProperty.vue
What is expected?
No type errors for ref, class and style properties in
.vue
file when using.tsx
file.No type errors for class and style properties in
.tsx
file when using.tsx
file.What is actually happening?
The class and style props and not present in the typing. This cause a ts error. For the
.vue
file, the ref is not present also.System Info
Any additional comments?
When looking in the type definition of
defineComponent
, the type returns a function instead of theDefineComponent
type. This is probably expected so the generic can work. I think some base props should be added, something like:The text was updated successfully, but these errors were encountered: