Skip to content
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

DefineComponent<typeof MyPropsObject> ruturn ComponentPublicInstanceConstructo<any, any, ...> #2192

Closed
Jokcy opened this issue Sep 21, 2020 · 3 comments

Comments

@Jokcy
Copy link
Contributor

Jokcy commented Sep 21, 2020

Version

3.0.0

Reproduction link

https://codesandbox.io/s/vue-3-ce53j?fontsize=14&hidenavigation=1&theme=dark

Steps to reproduce

I want to define my Component type using DefineComponent, something like:

type MyComponentType = DefineComponent<MyComponentPropsObject>

but the type returned is not correct, it returns ComponentPublicInstanceConstructo<any, any, ...>

What is expected?

return the correct type

What is actually happening?

return type not correct, it returns:

ComponentPublicInstanceConstructor<any, any, any, any, Record<string, ComputedGetter<any> | WritableComputedOptions<any>>, MethodOptions> & ComponentOptionsBase<...> & VNodeProps & AllowedComponentProps & ComponentCustomProps

did not find any online code editor support ts

@pikax
Copy link
Member

pikax commented Sep 22, 2020

The "reproduction link" is just a template, not a reproduction of your issue.

Please provide actual code.

@yyx990803
Copy link
Member

yyx990803 commented Sep 22, 2020

@pikax it's the case where user directly tries to use the DefineComponent type with optional generic arguments:

function test(C: DefineComponent<{ foo: string }>) {
  const c = new C() // type of c is `any`
}

Because optional RawBinding and D defaulting to any and then intersected on to the instance type.

@Jokcy
Copy link
Contributor Author

Jokcy commented Sep 23, 2020

Ah, why don't you just say type A = DefineComponent<typeof FiledPropsDefine, {}, {}> will solve this problem...

@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants