Skip to content

Commit

Permalink
fix: correctly infer TypeEmits with both tuple and function syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
KazariEX committed Sep 6, 2024
1 parent 632e163 commit 1d144aa
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions packages/runtime-core/src/componentEmits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,13 @@ export type EmitsToProps<T extends EmitsOptions | ComponentTypeEmits> =
}
: {}

export type TypeEmitsToOptions<T extends ComponentTypeEmits> =
T extends Record<string, any[]>
? {
[K in keyof T]: T[K] extends [...args: infer Args]
? (...args: Args) => any
: () => any
}
: T extends (...args: any[]) => any
? ParametersToFns<OverloadParameters<T>>
: {}
export type TypeEmitsToOptions<T extends ComponentTypeEmits> = {
[K in keyof T & string]: T[K] extends [...args: infer Args]
? (...args: Args) => any
: () => any
} & (T extends (...args: any[]) => any
? ParametersToFns<OverloadParameters<T>>
: {})

type ParametersToFns<T extends any[]> = {
[K in T[0]]: K extends `${infer C}`
Expand Down

0 comments on commit 1d144aa

Please sign in to comment.