@@ -41,6 +41,7 @@ export type DefineComponent<
41
41
Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
42
42
E extends EmitsOptions = { } ,
43
43
EE extends string = string ,
44
+ Attrs = { } ,
44
45
PP = PublicProps ,
45
46
Props = Readonly <
46
47
PropsOrPropOptions extends ComponentPropsOptions
@@ -61,7 +62,9 @@ export type DefineComponent<
61
62
E ,
62
63
PP & Props ,
63
64
Defaults ,
64
- true
65
+ true ,
66
+ { } ,
67
+ Attrs
65
68
> &
66
69
Props
67
70
> &
@@ -86,12 +89,12 @@ export type DefineComponent<
86
89
87
90
// overload 1: direct setup function
88
91
// (uses user defined props interface)
89
- export function defineComponent < Props , RawBindings = object > (
92
+ export function defineComponent < Props , RawBindings = object , Attrs = { } > (
90
93
setup : (
91
94
props : Readonly < Props > ,
92
- ctx : SetupContext
95
+ ctx : SetupContext < { } , Attrs >
93
96
) => RawBindings | RenderFunction
94
- ) : DefineComponent < Props , RawBindings >
97
+ ) : DefineComponent < Props , RawBindings , { } , { } , { } , { } , { } , { } , string , Attrs >
95
98
96
99
// overload 2: object format with no props
97
100
// (uses user defined props interface)
@@ -107,9 +110,10 @@ export function defineComponent<
107
110
E extends EmitsOptions = { } ,
108
111
EE extends string = string ,
109
112
I extends ComponentInjectOptions = { } ,
110
- II extends string = string
113
+ II extends string = string ,
114
+ Attrs = { }
111
115
> (
112
- options : ComponentOptionsWithoutProps <
116
+ comp : ComponentOptionsWithoutProps <
113
117
Props ,
114
118
RawBindings ,
115
119
D ,
@@ -120,9 +124,13 @@ export function defineComponent<
120
124
E ,
121
125
EE ,
122
126
I ,
123
- II
124
- >
125
- ) : DefineComponent < Props , RawBindings , D , C , M , Mixin , Extends , E , EE >
127
+ II ,
128
+ Attrs
129
+ > ,
130
+ options ?: {
131
+ attrs : Attrs
132
+ }
133
+ ) : DefineComponent < Props , RawBindings , D , C , M , Mixin , Extends , E , EE , Attrs >
126
134
127
135
// overload 3: object format with array props declaration
128
136
// props inferred as { [key in PropNames]?: any }
@@ -138,9 +146,10 @@ export function defineComponent<
138
146
E extends EmitsOptions = { } ,
139
147
EE extends string = string ,
140
148
I extends ComponentInjectOptions = { } ,
141
- II extends string = string
149
+ II extends string = string ,
150
+ Attrs = { }
142
151
> (
143
- options : ComponentOptionsWithArrayProps <
152
+ comp : ComponentOptionsWithArrayProps <
144
153
PropNames ,
145
154
RawBindings ,
146
155
D ,
@@ -151,8 +160,12 @@ export function defineComponent<
151
160
E ,
152
161
EE ,
153
162
I ,
154
- II
155
- >
163
+ II ,
164
+ Attrs
165
+ > ,
166
+ options ?: {
167
+ attrs : Attrs
168
+ }
156
169
) : DefineComponent <
157
170
Readonly < { [ key in PropNames ] ?: any } > ,
158
171
RawBindings ,
@@ -162,7 +175,8 @@ export function defineComponent<
162
175
Mixin ,
163
176
Extends ,
164
177
E ,
165
- EE
178
+ EE ,
179
+ Attrs
166
180
>
167
181
168
182
// overload 4: object format with object props declaration
@@ -180,9 +194,10 @@ export function defineComponent<
180
194
E extends EmitsOptions = { } ,
181
195
EE extends string = string ,
182
196
I extends ComponentInjectOptions = { } ,
183
- II extends string = string
197
+ II extends string = string ,
198
+ Attrs = { }
184
199
> (
185
- options : ComponentOptionsWithObjectProps <
200
+ comp : ComponentOptionsWithObjectProps <
186
201
PropsOptions ,
187
202
RawBindings ,
188
203
D ,
@@ -193,11 +208,26 @@ export function defineComponent<
193
208
E ,
194
209
EE ,
195
210
I ,
196
- II
197
- >
198
- ) : DefineComponent < PropsOptions , RawBindings , D , C , M , Mixin , Extends , E , EE >
211
+ II ,
212
+ Attrs
213
+ > ,
214
+ options ?: {
215
+ attrs : Attrs
216
+ }
217
+ ) : DefineComponent <
218
+ PropsOptions ,
219
+ RawBindings ,
220
+ D ,
221
+ C ,
222
+ M ,
223
+ Mixin ,
224
+ Extends ,
225
+ E ,
226
+ EE ,
227
+ Attrs
228
+ >
199
229
200
230
// implementation, close to no-op
201
- export function defineComponent ( options : unknown ) {
202
- return isFunction ( options ) ? { setup : options , name : options . name } : options
231
+ export function defineComponent ( comp : unknown , options ? : unknown ) {
232
+ return isFunction ( comp ) ? { setup : comp , name : comp . name } : comp
203
233
}
0 commit comments