@@ -39,23 +39,89 @@ function getSuperOptions(Ctor: Function): ComponentOptions | undefined {
39
39
return Super . __vccOpts
40
40
}
41
41
42
- export interface ClassComponentHooks {
43
- /* To be extended on user land */
44
- }
42
+ export interface VueStatic {
43
+ // -- Class component configs
44
+
45
+ /** @internal */
46
+ __vccCache ?: ComponentOptions
47
+
48
+ /** @internal */
49
+ __vccBase ?: ComponentOptions
50
+
51
+ /** @internal */
52
+ __vccDecorators ?: ( ( options : ComponentOptions ) => void ) [ ]
53
+
54
+ /** @internal */
55
+ __vccMixins ?: ComponentOptions [ ]
56
+
57
+ /** @internal */
58
+ __vccHooks : string [ ]
59
+
60
+ /** @internal */
61
+ __vccOpts : ComponentOptions
62
+
63
+ // --- Vue Loader injections
64
+
65
+ /** @internal */
66
+ render ?: ( ) => VNode | void
67
+
68
+ /** @internal */
69
+ __file ?: string
70
+
71
+ /** @internal */
72
+ __cssModules ?: Record < string , any >
73
+
74
+ /** @internal */
75
+ __scopeId ?: string
76
+
77
+ /** @internal */
78
+ __hmrId ?: string
79
+
80
+ // --- Public APIs
45
81
46
- export type VueStatic = {
47
- [ K in keyof typeof Vue ] : typeof Vue [ K ]
82
+ registerHooks ( keys : string [ ] ) : void
48
83
}
49
84
50
85
export type VueMixin < V extends Vue = Vue > = VueStatic & { prototype : V }
51
86
52
87
export type VueBase < V extends Vue = Vue > = VueMixin < V > &
53
88
( new ( ...args : any [ ] ) => V )
54
89
55
- export class Vue < Props = unknown >
56
- implements
57
- ComponentPublicInstance < { } , { } , { } , { } , { } , { } , Props > ,
58
- ClassComponentHooks {
90
+ export interface ClassComponentHooks {
91
+ // To be extended on user land
92
+
93
+ data ?( ) : object
94
+ beforeCreate ?( ) : void
95
+ created ?( ) : void
96
+ beforeMount ?( ) : void
97
+ mounted ?( ) : void
98
+ beforeUnmount ?( ) : void
99
+ unmounted ?( ) : void
100
+ beforeUpdate ?( ) : void
101
+ updated ?( ) : void
102
+ activated ?( ) : void
103
+ deactivated ?( ) : void
104
+ render ?( ) : VNode | void
105
+ errorCaptured ?( err : Error , vm : Vue , info : string ) : boolean | undefined
106
+ serverPrefetch ?( ) : Promise < unknown >
107
+ }
108
+
109
+ export type Vue < Props = unknown > = ComponentPublicInstance <
110
+ { } ,
111
+ { } ,
112
+ { } ,
113
+ { } ,
114
+ { } ,
115
+ { } ,
116
+ Props
117
+ > &
118
+ ClassComponentHooks
119
+
120
+ export interface VueConstructor extends VueStatic {
121
+ new < Props = unknown > ( prop : Props , ctx : SetupContext ) : Vue < Props >
122
+ }
123
+
124
+ class VueImpl {
59
125
/** @internal */
60
126
static __vccCache ?: ComponentOptions
61
127
@@ -147,7 +213,7 @@ export class Vue<Props = unknown>
147
213
}
148
214
} )
149
215
150
- options . setup = function ( props : unknown , ctx : SetupContext ) {
216
+ options . setup = function ( props : Record < string , any > , ctx : SetupContext ) {
151
217
const data : any = new Ctor ( props , ctx )
152
218
const dataKeys = Object . keys ( data )
153
219
@@ -188,10 +254,10 @@ export class Vue<Props = unknown>
188
254
'__cssModules' ,
189
255
'__scopeId' ,
190
256
'__hmrId' ,
191
- ] as const
257
+ ]
192
258
injections . forEach ( ( key ) => {
193
- if ( Ctor [ key ] ) {
194
- options [ key ] = Ctor [ key ]
259
+ if ( ( Ctor as any ) [ key ] ) {
260
+ options [ key ] = ( Ctor as any ) [ key ]
195
261
}
196
262
} )
197
263
@@ -202,47 +268,12 @@ export class Vue<Props = unknown>
202
268
this . __vccHooks . push ( ...keys )
203
269
}
204
270
205
- // Public instance properties
206
- $ ! : ComponentPublicInstance [ '$' ]
207
- $data ! : ComponentPublicInstance [ '$data' ]
208
- $refs ! : ComponentPublicInstance [ '$refs' ]
209
- $root ! : ComponentPublicInstance [ '$root' ]
210
- $parent ! : ComponentPublicInstance [ '$parent' ]
211
- $el ! : ComponentPublicInstance [ '$el' ]
212
- $options ! : ComponentPublicInstance [ '$options' ]
213
- $forceUpdate ! : ComponentPublicInstance [ '$forceUpdate' ]
214
- $nextTick ! : ComponentPublicInstance [ '$nextTick' ]
215
- $watch ! : ComponentPublicInstance [ '$watch' ]
216
-
217
- $props ! : Props
271
+ $props ! : Record < string , any >
218
272
$emit ! : ( event : string , ...args : any [ ] ) => void
219
273
$attrs ! : ComponentPublicInstance [ '$attrs' ]
220
274
$slots ! : ComponentPublicInstance [ '$slots' ]
221
275
222
- // Built-in hooks
223
- data ?( ) : object
224
- beforeCreate ?( ) : void
225
- created ?( ) : void
226
- beforeMount ?( ) : void
227
- mounted ?( ) : void
228
- beforeUnmount ?( ) : void
229
- unmounted ?( ) : void
230
- beforeUpdate ?( ) : void
231
- updated ?( ) : void
232
- activated ?( ) : void
233
- deactivated ?( ) : void
234
- render ?( ) : VNode | void
235
- errorCaptured ?( err : Error , vm : Vue , info : string ) : boolean | undefined
236
- serverPrefetch ?( ) : Promise < unknown >
237
-
238
- // Vue Loader injections
239
- static render ?: ( ) => VNode | void
240
- static __file ?: string
241
- static __cssModules ?: Record < string , any >
242
- static __scopeId ?: string
243
- static __hmrId ?: string
244
-
245
- constructor ( props : Props , ctx : SetupContext ) {
276
+ constructor ( props : Record < string , any > , ctx : SetupContext ) {
246
277
defineGetter ( this , '$props' , ( ) => props )
247
278
defineGetter ( this , '$attrs' , ( ) => ctx . attrs )
248
279
defineGetter ( this , '$slots' , ( ) => ctx . slots )
@@ -258,3 +289,5 @@ export class Vue<Props = unknown>
258
289
} )
259
290
}
260
291
}
292
+
293
+ export const Vue : VueConstructor = VueImpl as VueConstructor
0 commit comments