1
1
import { ExtractDefaultPropTypes , ExtractPropTypes } from './componentProps'
2
- import { ShallowUnwrapRef } from '..'
2
+ import {
3
+ nextTick ,
4
+ ShallowUnwrapRef ,
5
+ UnwrapNestedRefs ,
6
+ WatchOptions ,
7
+ WatchStopHandle ,
8
+ } from '..'
3
9
import { Data } from './common'
4
10
5
11
import Vue , {
@@ -11,6 +17,12 @@ import {
11
17
MethodOptions ,
12
18
ExtractComputedReturns ,
13
19
} from './componentOptions'
20
+ import {
21
+ ComponentInternalInstance ,
22
+ EmitFn ,
23
+ EmitsOptions ,
24
+ Slots ,
25
+ } from '../runtimeContext'
14
26
15
27
export type ComponentInstance = InstanceType < VueConstructor >
16
28
@@ -79,3 +91,42 @@ export type VueProxy<
79
91
ExtractPropTypes < PropsOptions >
80
92
> &
81
93
VueConstructorProxy < PropsOptions , RawBindings , Data , Computed , Methods >
94
+
95
+ // public properties exposed on the proxy, which is used as the render context
96
+ // in templates (as `this` in the render option)
97
+ export type ComponentPublicInstance <
98
+ P = { } , // props type extracted from props option
99
+ B = { } , // raw bindings returned from setup()
100
+ D = { } , // return from data()
101
+ C extends ComputedOptions = { } ,
102
+ M extends MethodOptions = { } ,
103
+ E extends EmitsOptions = { } ,
104
+ PublicProps = P ,
105
+ Defaults = { } ,
106
+ MakeDefaultsOptional extends boolean = false
107
+ > = {
108
+ $ : ComponentInternalInstance
109
+ $data : D
110
+ $props : MakeDefaultsOptional extends true
111
+ ? Partial < Defaults > & Omit < P & PublicProps , keyof Defaults >
112
+ : P & PublicProps
113
+ $attrs : Data
114
+ $refs : Data
115
+ $slots : Slots
116
+ $root : ComponentPublicInstance | null
117
+ $parent : ComponentPublicInstance | null
118
+ $emit : EmitFn < E >
119
+ $el : any
120
+ // $options: Options & MergedComponentOptionsOverride
121
+ $forceUpdate : ( ) => void
122
+ $nextTick : typeof nextTick
123
+ $watch (
124
+ source : string | Function ,
125
+ cb : Function ,
126
+ options ?: WatchOptions
127
+ ) : WatchStopHandle
128
+ } & P &
129
+ ShallowUnwrapRef < B > &
130
+ UnwrapNestedRefs < D > &
131
+ ExtractComputedReturns < C > &
132
+ M
0 commit comments