-
Notifications
You must be signed in to change notification settings - Fork 258
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
fix(types): Fix mount and shallowMount types #254
Conversation
export function mount<V, P>( | ||
originalComponent: { | ||
new (...args: any[]): V | ||
props(Props: P): any | ||
registerHooks(keys: string[]): void | ||
}, | ||
options?: MountingOptions<P> | ||
): VueWrapper<ComponentPublicInstance<V>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export function mount<V, P>( | |
originalComponent: { | |
new (...args: any[]): V | |
props(Props: P): any | |
registerHooks(keys: string[]): void | |
}, | |
options?: MountingOptions<P> | |
): VueWrapper<ComponentPublicInstance<V>> | |
export function mount<V extends ComponentPublicInstance<P>, P>( | |
originalComponent: { | |
new (...args: any[]): V | |
}, | |
options?: MountingOptions<P> | |
): VueWrapper<V> |
As class component implements component public instance, just using the interface should be enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a bit too lenient, because the defineComponent
will also return a valid component public instance to be used on JSX
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, agree, having props
intellisense is pretty cool. I don't think it's possible for data
in class component though.
@pikax is this good to go? Seems fine to me - are you still thinking about this typing or should we merge and release this? |
@lmiller1990 I'm good with this typing |
fix #251
This was caused because
vue-class-component
dependency was not made optional or as a dev, so the importVueContructor
would always beany
, making all themount
andshallowMount
to be caught by that overload.I've removed the dependency on
VueContructor
on themount
, made it a bit more generic, this might break if the types changes on thevue-class-component
(which I think is unlikely)@ktsn can you just validate if this overload is enough?