Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: vuejs/test-utils
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 87802d71de47e50f60bcb971b8d92c911f16337f
Choose a base ref
..
head repository: vuejs/test-utils
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1f1c3e633289205b2235baa392bf37fee3bdf968
Choose a head ref
Showing with 7 additions and 11 deletions.
  1. +7 −11 src/vueWrapper.ts
18 changes: 7 additions & 11 deletions src/vueWrapper.ts
Original file line number Diff line number Diff line change
@@ -80,21 +80,17 @@ function createVMProxy<T extends ComponentPublicInstance>(

type ResolveComponentEmitKeys<T> = keyof ResolveEmitRecord<T>

type ExtractArgType<T extends Array<any>> = T extends { length: 0 }
? void
: T extends { length: 1 }
? T[0]
: T

type ExtractEmitType<T> = T extends (...args: infer Args) => any
? ExtractArgType<Args>
: void

type ResolveEmitRecord<T> = ExtractComponentEmits<T> extends infer E
? [E] extends [Array<infer EE extends string>]
? Record<EE, any[]>
: {
[K in keyof E]: ExtractEmitType<E[K]>[]
[K in keyof E]: (E[K] extends (...args: infer Args) => any
? Args extends { length: 0 }
? void
: Args extends { length: 1 }
? Args[0]
: Args
: void)[]
}
: never