@@ -42,7 +42,11 @@ import {
4242 WritableComputedOptions ,
4343 toRaw
4444} from '@vue/reactivity'
45- import { ComponentObjectPropsOptions , ExtractPropTypes } from './componentProps'
45+ import {
46+ ComponentObjectPropsOptions ,
47+ ExtractPropTypes ,
48+ ExtractDefaultPropTypes
49+ } from './componentProps'
4650import { EmitsOptions } from './componentEmits'
4751import { Directive } from './directives'
4852import {
@@ -81,7 +85,8 @@ export interface ComponentOptionsBase<
8185 Mixin extends ComponentOptionsMixin ,
8286 Extends extends ComponentOptionsMixin ,
8387 E extends EmitsOptions ,
84- EE extends string = string
88+ EE extends string = string ,
89+ Defaults = { }
8590>
8691 extends LegacyOptions < Props , D , C , M , Mixin , Extends > ,
8792 ComponentInternalOptions ,
@@ -148,6 +153,8 @@ export interface ComponentOptionsBase<
148153 __isFragment ?: never
149154 __isTeleport ?: never
150155 __isSuspense ?: never
156+
157+ __defaults ?: Defaults
151158}
152159
153160export type ComponentOptionsWithoutProps <
@@ -159,8 +166,20 @@ export type ComponentOptionsWithoutProps<
159166 Mixin extends ComponentOptionsMixin = ComponentOptionsMixin ,
160167 Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
161168 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+ > & {
164183 props ?: undefined
165184} & ThisType <
166185 CreateComponentPublicInstance <
@@ -172,7 +191,9 @@ export type ComponentOptionsWithoutProps<
172191 Mixin ,
173192 Extends ,
174193 E ,
175- Readonly < Props >
194+ Readonly < Props > ,
195+ Defaults ,
196+ false
176197 >
177198 >
178199
@@ -187,7 +208,18 @@ export type ComponentOptionsWithArrayProps<
187208 E extends EmitsOptions = EmitsOptions ,
188209 EE extends string = string ,
189210 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+ > & {
191223 props : PropNames [ ]
192224} & ThisType <
193225 CreateComponentPublicInstance <
@@ -212,8 +244,20 @@ export type ComponentOptionsWithObjectProps<
212244 Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
213245 E extends EmitsOptions = EmitsOptions ,
214246 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+ > & {
217261 props : PropsOptions & ThisType < void >
218262} & ThisType <
219263 CreateComponentPublicInstance <
@@ -224,7 +268,10 @@ export type ComponentOptionsWithObjectProps<
224268 M ,
225269 Mixin ,
226270 Extends ,
227- E
271+ E ,
272+ Props ,
273+ Defaults ,
274+ false
228275 >
229276 >
230277
@@ -261,6 +308,7 @@ export type ComponentOptionsMixin = ComponentOptionsBase<
261308 any ,
262309 any ,
263310 any ,
311+ any ,
264312 any
265313>
266314
@@ -347,20 +395,22 @@ interface LegacyOptions<
347395 delimiters ?: [ string , string ]
348396}
349397
350- export type OptionTypesKeys = 'P' | 'B' | 'D' | 'C' | 'M'
398+ export type OptionTypesKeys = 'P' | 'B' | 'D' | 'C' | 'M' | 'Defaults'
351399
352400export type OptionTypesType <
353401 P = { } ,
354402 B = { } ,
355403 D = { } ,
356404 C extends ComputedOptions = { } ,
357- M extends MethodOptions = { }
405+ M extends MethodOptions = { } ,
406+ Defaults = { }
358407> = {
359408 P : P
360409 B : B
361410 D : D
362411 C : C
363412 M : M
413+ Defaults : Defaults
364414}
365415
366416const enum OptionTypes {
0 commit comments