@@ -41,6 +41,7 @@ export type DefineComponent<
4141 Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
4242 E extends EmitsOptions = { } ,
4343 EE extends string = string ,
44+ Attrs = { } ,
4445 PP = PublicProps ,
4546 Props = Readonly <
4647 PropsOrPropOptions extends ComponentPropsOptions
@@ -61,7 +62,9 @@ export type DefineComponent<
6162 E ,
6263 PP & Props ,
6364 Defaults ,
64- true
65+ true ,
66+ { } ,
67+ Attrs
6568 > &
6669 Props
6770> &
@@ -86,12 +89,12 @@ export type DefineComponent<
8689
8790// overload 1: direct setup function
8891// (uses user defined props interface)
89- export function defineComponent < Props , RawBindings = object > (
92+ export function defineComponent < Props , RawBindings = object , Attrs = { } > (
9093 setup : (
9194 props : Readonly < Props > ,
92- ctx : SetupContext
95+ ctx : SetupContext < { } , Attrs >
9396 ) => RawBindings | RenderFunction
94- ) : DefineComponent < Props , RawBindings >
97+ ) : DefineComponent < Props , RawBindings , { } , { } , { } , { } , { } , { } , string , Attrs >
9598
9699// overload 2: object format with no props
97100// (uses user defined props interface)
@@ -107,9 +110,10 @@ export function defineComponent<
107110 E extends EmitsOptions = { } ,
108111 EE extends string = string ,
109112 I extends ComponentInjectOptions = { } ,
110- II extends string = string
113+ II extends string = string ,
114+ Attrs = { }
111115> (
112- options : ComponentOptionsWithoutProps <
116+ comp : ComponentOptionsWithoutProps <
113117 Props ,
114118 RawBindings ,
115119 D ,
@@ -120,9 +124,13 @@ export function defineComponent<
120124 E ,
121125 EE ,
122126 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 >
126134
127135// overload 3: object format with array props declaration
128136// props inferred as { [key in PropNames]?: any }
@@ -138,9 +146,10 @@ export function defineComponent<
138146 E extends EmitsOptions = { } ,
139147 EE extends string = string ,
140148 I extends ComponentInjectOptions = { } ,
141- II extends string = string
149+ II extends string = string ,
150+ Attrs = { }
142151> (
143- options : ComponentOptionsWithArrayProps <
152+ comp : ComponentOptionsWithArrayProps <
144153 PropNames ,
145154 RawBindings ,
146155 D ,
@@ -151,8 +160,12 @@ export function defineComponent<
151160 E ,
152161 EE ,
153162 I ,
154- II
155- >
163+ II ,
164+ Attrs
165+ > ,
166+ options ?: {
167+ attrs : Attrs
168+ }
156169) : DefineComponent <
157170 Readonly < { [ key in PropNames ] ?: any } > ,
158171 RawBindings ,
@@ -162,7 +175,8 @@ export function defineComponent<
162175 Mixin ,
163176 Extends ,
164177 E ,
165- EE
178+ EE ,
179+ Attrs
166180>
167181
168182// overload 4: object format with object props declaration
@@ -180,9 +194,10 @@ export function defineComponent<
180194 E extends EmitsOptions = { } ,
181195 EE extends string = string ,
182196 I extends ComponentInjectOptions = { } ,
183- II extends string = string
197+ II extends string = string ,
198+ Attrs = { }
184199> (
185- options : ComponentOptionsWithObjectProps <
200+ comp : ComponentOptionsWithObjectProps <
186201 PropsOptions ,
187202 RawBindings ,
188203 D ,
@@ -193,11 +208,26 @@ export function defineComponent<
193208 E ,
194209 EE ,
195210 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+ >
199229
200230// 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
203233}
0 commit comments