From dad673809929c084dcb8e42640eb7daa675d4ea4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=B1=B1=E5=90=B9=E8=89=B2=E5=BE=A1=E5=AE=88?= <85992002+KazariEX@users.noreply.github.com> Date: Fri, 6 Sep 2024 16:10:56 +0800 Subject: [PATCH] fix(types): correctly infer `TypeEmits` with both tuple and function syntax (#11840) close #11836 --- packages/runtime-core/src/componentEmits.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/packages/runtime-core/src/componentEmits.ts b/packages/runtime-core/src/componentEmits.ts index dddb2e9453..b1be1c9ed0 100644 --- a/packages/runtime-core/src/componentEmits.ts +++ b/packages/runtime-core/src/componentEmits.ts @@ -57,16 +57,13 @@ export type EmitsToProps = } : {} -export type TypeEmitsToOptions = - T extends Record - ? { - [K in keyof T]: T[K] extends [...args: infer Args] - ? (...args: Args) => any - : () => any - } - : T extends (...args: any[]) => any - ? ParametersToFns> - : {} +export type TypeEmitsToOptions = { + [K in keyof T & string]: T[K] extends [...args: infer Args] + ? (...args: Args) => any + : () => any +} & (T extends (...args: any[]) => any + ? ParametersToFns> + : {}) type ParametersToFns = { [K in T[0]]: K extends `${infer C}` -- 2.47.3