Skip to content

Commit 565cbd1

Browse files
committed
fix(types): align emits type with vue-next
1 parent cb60681 commit 565cbd1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/component/componentOptions.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ export { ComponentPropsOptions } from './componentProps'
88
export type ComputedGetter<T> = (ctx?: any) => T
99
export type ComputedSetter<T> = (v: T) => void
1010

11+
export type ObjectEmitsOptions = Record<
12+
string,
13+
((...args: any[]) => any) | null
14+
>
15+
16+
export type EmitsOptions = ObjectEmitsOptions | string[]
17+
1118
export interface WritableComputedOptions<T> {
1219
get: ComputedGetter<T>
1320
set: ComputedSetter<T>
@@ -63,7 +70,7 @@ export type ComponentOptionsWithProps<
6370
Props = ExtractPropTypes<PropsOptions>
6471
> = ComponentOptionsBase<Props, D, C, M> & {
6572
props?: PropsOptions
66-
emits?: string[] | Record<string, null | ((emitData: any) => boolean)>
73+
emits?: (EmitsOptions | string[]) & ThisType<void>
6774
setup?: SetupFunction<Props, RawBindings>
6875
} & ThisType<ComponentRenderProxy<Props, RawBindings, D, C, M>>
6976

@@ -76,7 +83,7 @@ export type ComponentOptionsWithArrayProps<
7683
Props = Readonly<{ [key in PropNames]?: any }>
7784
> = ComponentOptionsBase<Props, D, C, M> & {
7885
props?: PropNames[]
79-
emits?: string[] | Record<string, null | ((emitData: any) => boolean)>
86+
emits?: (EmitsOptions | string[]) & ThisType<void>
8087
setup?: SetupFunction<Props, RawBindings>
8188
} & ThisType<ComponentRenderProxy<Props, RawBindings, D, C, M>>
8289

@@ -88,7 +95,7 @@ export type ComponentOptionsWithoutProps<
8895
M extends MethodOptions = {}
8996
> = ComponentOptionsBase<Props, D, C, M> & {
9097
props?: undefined
91-
emits?: string[] | Record<string, null | ((emitData: any) => boolean)>
98+
emits?: (EmitsOptions | string[]) & ThisType<void>
9299
setup?: SetupFunction<Props, RawBindings>
93100
} & ThisType<ComponentRenderProxy<Props, RawBindings, D, C, M>>
94101

0 commit comments

Comments
 (0)