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

WIP: Support for vue type helpers changes #2242

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
fix
pikax committed Nov 16, 2023
commit f4934bf4f89ba401d2e3cf2987c37f2bdde15264
26 changes: 5 additions & 21 deletions src/vueWrapper.ts
Original file line number Diff line number Diff line change
@@ -3,8 +3,7 @@ import {
App,
ComponentPublicInstance,
VNode,
ExtractComponentEmits,
ComponentCustomProperties
ExtractComponentEmits
} from 'vue'

import { config } from './config'
@@ -95,23 +94,9 @@ type ResolveEmitRecord<T> = ExtractComponentEmits<T> extends infer E
}
: never

declare const aaa: keyof Omit<
ComponentPublicInstance,
keyof ComponentCustomProperties
>

// type BetterKeys = keyof Omit<
// ComponentPublicInstance,
// keyof ComponentCustomProperties
// >
// export type ComponentInstance = {
// [K in keyof ComponentPublicInstance]?: any
// } & Record<PropertyKey, any>

export class VueWrapper<
T extends Omit<ComponentPublicInstance, '$emit'> & {
$emit: any
} = ComponentPublicInstance
VM = unknown,
T extends ComponentPublicInstance = ComponentPublicInstance & VM
> extends BaseWrapper<Node> {
private readonly componentVM: T
private readonly rootVM: ComponentPublicInstance | undefined | null
@@ -251,7 +236,6 @@ export class VueWrapper<
get vm(): T {
return this.componentVM
}

props(): T['$props']
props<Selector extends keyof T['$props']>(
selector: Selector
@@ -264,9 +248,9 @@ export class VueWrapper<
}

emitted(): ResolveEmitRecord<T>
emitted<E extends ResolveComponentEmitKeys<T>>(
emitted<E extends ResolveComponentEmitKeys<VM>>(
eventName: E
): undefined | ResolveEmitRecord<T>[E]
): undefined | ResolveEmitRecord<VM>[E]
emitted(eventName?: string) {
return emitted(this.vm, eventName)
}
2 changes: 1 addition & 1 deletion src/wrapperFactory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ComponentPublicInstance, App } from 'vue'
import { App, ComponentPublicInstance } from 'vue'
import type { DOMWrapper as DOMWrapperType } from './domWrapper'
import type { VueWrapper as VueWrapperType } from './vueWrapper'