From: 山吹色御守 <85992002+KazariEX@users.noreply.github.com> Date: Fri, 6 Sep 2024 08:10:56 +0000 (+0800) Subject: fix(types): correctly infer `TypeEmits` with both tuple and function syntax (#11840) X-Git-Tag: v3.5.4~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dad673809929c084dcb8e42640eb7daa675d4ea4;p=thirdparty%2Fvuejs%2Fcore.git fix(types): correctly infer `TypeEmits` with both tuple and function syntax (#11840) close #11836 --- 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}`