From a6503e3e77b04a1ab8c07078e07091b06d51131d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=B6=E8=BF=9C=E6=96=B9?= Date: Mon, 11 Dec 2023 20:01:36 +0800 Subject: [PATCH] refactor(types): simplify `EmitsToProps` types (#9788) --- packages/runtime-core/src/componentEmits.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/packages/runtime-core/src/componentEmits.ts b/packages/runtime-core/src/componentEmits.ts index f3a30f7c953..d56877adb58 100644 --- a/packages/runtime-core/src/componentEmits.ts +++ b/packages/runtime-core/src/componentEmits.ts @@ -38,19 +38,18 @@ export type EmitsOptions = ObjectEmitsOptions | string[] export type EmitsToProps = T extends string[] ? { - [K in string & `on${Capitalize}`]?: (...args: any[]) => any + [K in `on${Capitalize}`]?: (...args: any[]) => any } : T extends ObjectEmitsOptions ? { - [K in string & - `on${Capitalize}`]?: K extends `on${infer C}` - ? T[Uncapitalize] extends null - ? (...args: any[]) => any - : ( - ...args: T[Uncapitalize] extends (...args: infer P) => any - ? P + [K in `on${Capitalize}`]?: K extends `on${infer C}` + ? ( + ...args: T[Uncapitalize] extends (...args: infer P) => any + ? P + : T[Uncapitalize] extends null + ? any[] : never - ) => any + ) => any : never } : {}