@@ -50,12 +50,14 @@ export interface ComponentOptionsBase<
5050 RawBindings ,
5151 D ,
5252 C extends ComputedOptions ,
53- M extends MethodOptions
54- > extends LegacyOptions < Props , RawBindings , D , C , M > , SFCInternalOptions {
53+ M extends MethodOptions ,
54+ E extends EmitsOptions ,
55+ EE extends string = string
56+ > extends LegacyOptions < Props , D , C , M > , SFCInternalOptions {
5557 setup ?: (
5658 this : void ,
5759 props : Props ,
58- ctx : SetupContext
60+ ctx : SetupContext < E >
5961 ) => RawBindings | RenderFunction | void
6062 name ?: string
6163 template ?: string | object // can be a direct DOM node
@@ -75,6 +77,7 @@ export interface ComponentOptionsBase<
7577 components ?: Record < string , PublicAPIComponent >
7678 directives ?: Record < string , Directive >
7779 inheritAttrs ?: boolean
80+ emits ?: E | EE [ ]
7881
7982 // Internal ------------------------------------------------------------------
8083
@@ -97,32 +100,40 @@ export type ComponentOptionsWithoutProps<
97100 RawBindings = { } ,
98101 D = { } ,
99102 C extends ComputedOptions = { } ,
100- M extends MethodOptions = { }
101- > = ComponentOptionsBase < Props , RawBindings , D , C , M > & {
103+ M extends MethodOptions = { } ,
104+ E extends EmitsOptions = Record < string , any > ,
105+ EE extends string = string
106+ > = ComponentOptionsBase < Props , RawBindings , D , C , M , E , EE > & {
102107 props ?: undefined
103- } & ThisType < ComponentPublicInstance < { } , RawBindings , D , C , M , Readonly < Props > > >
108+ } & ThisType <
109+ ComponentPublicInstance < { } , RawBindings , D , C , M , E , Readonly < Props > >
110+ >
104111
105112export type ComponentOptionsWithArrayProps <
106113 PropNames extends string = string ,
107114 RawBindings = { } ,
108115 D = { } ,
109116 C extends ComputedOptions = { } ,
110117 M extends MethodOptions = { } ,
118+ E extends EmitsOptions = Record < string , any > ,
119+ EE extends string = string ,
111120 Props = Readonly < { [ key in PropNames ] ?: any } >
112- > = ComponentOptionsBase < Props , RawBindings , D , C , M > & {
121+ > = ComponentOptionsBase < Props , RawBindings , D , C , M , E , EE > & {
113122 props : PropNames [ ]
114- } & ThisType < ComponentPublicInstance < Props , RawBindings , D , C , M > >
123+ } & ThisType < ComponentPublicInstance < Props , RawBindings , D , C , M , E > >
115124
116125export type ComponentOptionsWithObjectProps <
117126 PropsOptions = ComponentObjectPropsOptions ,
118127 RawBindings = { } ,
119128 D = { } ,
120129 C extends ComputedOptions = { } ,
121130 M extends MethodOptions = { } ,
131+ E extends EmitsOptions = Record < string , any > ,
132+ EE extends string = string ,
122133 Props = Readonly < ExtractPropTypes < PropsOptions > >
123- > = ComponentOptionsBase < Props , RawBindings , D , C , M > & {
134+ > = ComponentOptionsBase < Props , RawBindings , D , C , M , E , EE > & {
124135 props : PropsOptions
125- } & ThisType < ComponentPublicInstance < Props , RawBindings , D , C , M > >
136+ } & ThisType < ComponentPublicInstance < Props , RawBindings , D , C , M , E > >
126137
127138export type ComponentOptions =
128139 | ComponentOptionsWithoutProps < any , any , any , any , any >
@@ -138,6 +149,8 @@ export interface MethodOptions {
138149 [ key : string ] : Function
139150}
140151
152+ export type EmitsOptions = Record < string , any > | string [ ]
153+
141154export type ExtractComputedReturns < T extends any > = {
142155 [ key in keyof T ] : T [ key ] extends { get : Function }
143156 ? ReturnType < T [ key ] [ 'get' ] >
@@ -162,7 +175,6 @@ type ComponentInjectOptions =
162175
163176export interface LegacyOptions <
164177 Props ,
165- RawBindings ,
166178 D ,
167179 C extends ComputedOptions ,
168180 M extends MethodOptions
0 commit comments