From 565cbd1ba7e6944b87e5fab129ba1830d02aeab7 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Tue, 31 Aug 2021 17:22:32 +0800 Subject: [PATCH] fix(types): align emits type with vue-next --- src/component/componentOptions.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/component/componentOptions.ts b/src/component/componentOptions.ts index 117cd511..21083455 100644 --- a/src/component/componentOptions.ts +++ b/src/component/componentOptions.ts @@ -8,6 +8,13 @@ export { ComponentPropsOptions } from './componentProps' export type ComputedGetter = (ctx?: any) => T export type ComputedSetter = (v: T) => void +export type ObjectEmitsOptions = Record< + string, + ((...args: any[]) => any) | null +> + +export type EmitsOptions = ObjectEmitsOptions | string[] + export interface WritableComputedOptions { get: ComputedGetter set: ComputedSetter @@ -63,7 +70,7 @@ export type ComponentOptionsWithProps< Props = ExtractPropTypes > = ComponentOptionsBase & { props?: PropsOptions - emits?: string[] | Record boolean)> + emits?: (EmitsOptions | string[]) & ThisType setup?: SetupFunction } & ThisType> @@ -76,7 +83,7 @@ export type ComponentOptionsWithArrayProps< Props = Readonly<{ [key in PropNames]?: any }> > = ComponentOptionsBase & { props?: PropNames[] - emits?: string[] | Record boolean)> + emits?: (EmitsOptions | string[]) & ThisType setup?: SetupFunction } & ThisType> @@ -88,7 +95,7 @@ export type ComponentOptionsWithoutProps< M extends MethodOptions = {} > = ComponentOptionsBase & { props?: undefined - emits?: string[] | Record boolean)> + emits?: (EmitsOptions | string[]) & ThisType setup?: SetupFunction } & ThisType>