@@ -365,15 +365,27 @@ Converts an Record<string, any> into a props definition like object.
365365Useful for extending component props.
366366
367367```ts
368-
368+ const props: ObjectToComponentProps<{ foo : ' bar' | ' baz' , baz ?: number } >
369+ // props is:
370+ {
371+ foo : {
372+ type: Prop < ' bar' | ' baz' > ,
373+ required: true
374+ },
375+ baz : {
376+ type: Prop < number > ,
377+ required: false
378+ }
379+ }
369380```
370381
371382## ComponentEmitsAsProps\<T > { #componentemitsasprops }
372383
373- Converts `Emit` declaration into `props` declaration.
384+ Converts `Emit` declaration into `props` declaration, returned object will be optional .
374385
375386```ts
376-
387+ declare const emit: ComponentEmitsAsProps<{ emits : { foo : () => true } } >
388+ emit.onFoo?.() // ok
377389```
378390
379391## ComponentProps\<T > { #componentprops }
@@ -395,23 +407,53 @@ props.foo // string | undefined
395407Returns runtime slots for a component.
396408
397409```ts
410+ const Comp = defineComponent({
411+ slots : {} as SlotsType <{
412+ default: (arg : { msg: string }) => any
413+ }>
414+ } )
398415
416+ const slots = { } as ComponentSlots<typeof Comp >
417+ slots.default // { arg : { msg: string } } => any
399418```
400419
401420## ComponentEmit\<T > { #componentemit }
402421
403422Returns the `emit` function from options.
404423
405424```ts
425+ const CompSlotsTyped = defineComponent({
426+ emits : {
427+ foo : (arg : string ) => true
428+ }
429+ } )
406430
431+ const emit = { } as ComponentEmit<typeof CompSlotsTyped >
432+ emit // (event: 'foo', arg: string) => void
407433```
408434
409435## ComponentData\<T > { #componentdata }
410436
411437Returns the component bindings from `data` and `setup`.
412438
413439```ts
440+ const Comp = defineComponent({
441+ data () {
442+ return {
443+ foo : ' string'
444+ }
445+ },
446+
447+ setup (props , ctx ) {
448+ return {
449+ bar : 42
450+ }
451+ }
452+ } )
414453
454+ const data = { } as ComponentData<typeof Comp >
455+ data.foo // string
456+ data.bar // number
415457```
416458
417459## DefineComponentOptions & DefineComponentFromOptions { #definecomponentoptions }
@@ -479,4 +521,3 @@ declare function defineComponentWithDefaults<
479521 Options
480522>
481523```
482-
0 commit comments