@@ -42,7 +42,11 @@ import {
42
42
WritableComputedOptions ,
43
43
toRaw
44
44
} from '@vue/reactivity'
45
- import { ComponentObjectPropsOptions , ExtractPropTypes } from './componentProps'
45
+ import {
46
+ ComponentObjectPropsOptions ,
47
+ ExtractPropTypes ,
48
+ ExtractDefaultPropTypes
49
+ } from './componentProps'
46
50
import { EmitsOptions } from './componentEmits'
47
51
import { Directive } from './directives'
48
52
import {
@@ -81,7 +85,8 @@ export interface ComponentOptionsBase<
81
85
Mixin extends ComponentOptionsMixin ,
82
86
Extends extends ComponentOptionsMixin ,
83
87
E extends EmitsOptions ,
84
- EE extends string = string
88
+ EE extends string = string ,
89
+ Defaults = { }
85
90
>
86
91
extends LegacyOptions < Props , D , C , M , Mixin , Extends > ,
87
92
ComponentInternalOptions ,
@@ -148,6 +153,8 @@ export interface ComponentOptionsBase<
148
153
__isFragment ?: never
149
154
__isTeleport ?: never
150
155
__isSuspense ?: never
156
+
157
+ __defaults ?: Defaults
151
158
}
152
159
153
160
export type ComponentOptionsWithoutProps <
@@ -159,8 +166,20 @@ export type ComponentOptionsWithoutProps<
159
166
Mixin extends ComponentOptionsMixin = ComponentOptionsMixin ,
160
167
Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
161
168
E extends EmitsOptions = EmitsOptions ,
162
- EE extends string = string
163
- > = ComponentOptionsBase < Props , RawBindings , D , C , M , Mixin , Extends , E , EE > & {
169
+ EE extends string = string ,
170
+ Defaults = { }
171
+ > = ComponentOptionsBase <
172
+ Props ,
173
+ RawBindings ,
174
+ D ,
175
+ C ,
176
+ M ,
177
+ Mixin ,
178
+ Extends ,
179
+ E ,
180
+ EE ,
181
+ Defaults
182
+ > & {
164
183
props ?: undefined
165
184
} & ThisType <
166
185
CreateComponentPublicInstance <
@@ -172,7 +191,9 @@ export type ComponentOptionsWithoutProps<
172
191
Mixin ,
173
192
Extends ,
174
193
E ,
175
- Readonly < Props >
194
+ Readonly < Props > ,
195
+ Defaults ,
196
+ false
176
197
>
177
198
>
178
199
@@ -187,7 +208,18 @@ export type ComponentOptionsWithArrayProps<
187
208
E extends EmitsOptions = EmitsOptions ,
188
209
EE extends string = string ,
189
210
Props = Readonly < { [ key in PropNames ] ?: any } >
190
- > = ComponentOptionsBase < Props , RawBindings , D , C , M , Mixin , Extends , E , EE > & {
211
+ > = ComponentOptionsBase <
212
+ Props ,
213
+ RawBindings ,
214
+ D ,
215
+ C ,
216
+ M ,
217
+ Mixin ,
218
+ Extends ,
219
+ E ,
220
+ EE ,
221
+ { }
222
+ > & {
191
223
props : PropNames [ ]
192
224
} & ThisType <
193
225
CreateComponentPublicInstance <
@@ -212,8 +244,20 @@ export type ComponentOptionsWithObjectProps<
212
244
Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
213
245
E extends EmitsOptions = EmitsOptions ,
214
246
EE extends string = string ,
215
- Props = Readonly < ExtractPropTypes < PropsOptions > >
216
- > = ComponentOptionsBase < Props , RawBindings , D , C , M , Mixin , Extends , E , EE > & {
247
+ Props = Readonly < ExtractPropTypes < PropsOptions > > ,
248
+ Defaults = ExtractDefaultPropTypes < PropsOptions >
249
+ > = ComponentOptionsBase <
250
+ Props ,
251
+ RawBindings ,
252
+ D ,
253
+ C ,
254
+ M ,
255
+ Mixin ,
256
+ Extends ,
257
+ E ,
258
+ EE ,
259
+ Defaults
260
+ > & {
217
261
props : PropsOptions & ThisType < void >
218
262
} & ThisType <
219
263
CreateComponentPublicInstance <
@@ -224,7 +268,10 @@ export type ComponentOptionsWithObjectProps<
224
268
M ,
225
269
Mixin ,
226
270
Extends ,
227
- E
271
+ E ,
272
+ Props ,
273
+ Defaults ,
274
+ false
228
275
>
229
276
>
230
277
@@ -261,6 +308,7 @@ export type ComponentOptionsMixin = ComponentOptionsBase<
261
308
any ,
262
309
any ,
263
310
any ,
311
+ any ,
264
312
any
265
313
>
266
314
@@ -347,20 +395,22 @@ interface LegacyOptions<
347
395
delimiters ?: [ string , string ]
348
396
}
349
397
350
- export type OptionTypesKeys = 'P' | 'B' | 'D' | 'C' | 'M'
398
+ export type OptionTypesKeys = 'P' | 'B' | 'D' | 'C' | 'M' | 'Defaults'
351
399
352
400
export type OptionTypesType <
353
401
P = { } ,
354
402
B = { } ,
355
403
D = { } ,
356
404
C extends ComputedOptions = { } ,
357
- M extends MethodOptions = { }
405
+ M extends MethodOptions = { } ,
406
+ Defaults = { }
358
407
> = {
359
408
P : P
360
409
B : B
361
410
D : D
362
411
C : C
363
412
M : M
413
+ Defaults : Defaults
364
414
}
365
415
366
416
const enum OptionTypes {
0 commit comments