diff --git a/packages/playwright-ct-vue2/index.d.ts b/packages/playwright-ct-vue2/index.d.ts index 08046733c5..3f1c8c5b0d 100644 --- a/packages/playwright-ct-vue2/index.d.ts +++ b/packages/playwright-ct-vue2/index.d.ts @@ -36,20 +36,30 @@ export type PlaywrightTestConfig = Omit & { default?: Slot }; -export interface MountOptions< - HooksConfig extends JsonObject, - Props extends Record -> { - props?: Props; - slots?: Record & { default?: Slot }; - on?: Record; +type ComponentEvents = Record; + +// Copied from: https://github.com/vuejs/language-tools/blob/master/packages/vue-component-type-helpers/index.d.ts#L10-L13 +type ComponentProps = + T extends new () => { $props: infer P; } ? NonNullable

: + T extends (props: infer P, ...args: any) => any ? P : + {}; + +export interface MountOptions { + props?: ComponentProps; + slots?: ComponentSlots; + on?: ComponentEvents; hooksConfig?: HooksConfig; } -interface MountResult> extends Locator { +interface MountResult extends Locator { unmount(): Promise; - update(options: Omit, 'hooksConfig'>): Promise; + update(options: { + props?: Partial>; + slots?: Partial; + on?: Partial; + }): Promise; } interface MountResultJsx extends Locator { @@ -59,17 +69,10 @@ interface MountResultJsx extends Locator { export interface ComponentFixtures { mount(component: JSX.Element): Promise; - mount( - component: any, - options?: MountOptions> - ): Promise>>; - mount< - HooksConfig extends JsonObject, - Props extends Record = Record - >( - component: any, - options: MountOptions & { props: Props } - ): Promise>; + mount( + component: Component, + options?: MountOptions + ): Promise>; } export const test: TestType< @@ -77,9 +80,6 @@ export const test: TestType< PlaywrightWorkerArgs & PlaywrightWorkerOptions >; -/** - * Defines Playwright config - */ export function defineConfig(config: PlaywrightTestConfig): PlaywrightTestConfig; export function defineConfig(config: PlaywrightTestConfig): PlaywrightTestConfig; export function defineConfig(config: PlaywrightTestConfig): PlaywrightTestConfig;