@@ -7,6 +7,10 @@ import {
7
7
WatchHandler ,
8
8
DirectiveOptions ,
9
9
DirectiveFunction ,
10
+ PropValidator ,
11
+ ThisTypedComponentOptionsWithArrayProps ,
12
+ ThisTypedComponentOptionsWithRecordProps ,
13
+ MyAsyncComponent ,
10
14
} from "./options" ;
11
15
import { VNode , VNodeData , VNodeChildren , ScopedSlot } from "./vnode" ;
12
16
import { PluginFunction , PluginObject } from "./plugin" ;
@@ -20,29 +24,30 @@ export type CreateElement = {
20
24
( tag : string , data ?: VNodeData , children ?: VNodeChildren ) : VNode ;
21
25
22
26
// component constructor or options
23
- ( tag : Component , children : VNodeChildren ) : VNode ;
24
- ( tag : Component , data ?: VNodeData , children ?: VNodeChildren ) : VNode ;
27
+ ( tag : Component < any , any , any , any > , children : VNodeChildren ) : VNode ;
28
+ ( tag : Component < any , any , any , any > , data ?: VNodeData , children ?: VNodeChildren ) : VNode ;
25
29
26
30
// async component
27
- ( tag : AsyncComponent , children : VNodeChildren ) : VNode ;
28
- ( tag : AsyncComponent , data ?: VNodeData , children ?: VNodeChildren ) : VNode ;
31
+ ( tag : AsyncComponent < any , any , any , any > , children : VNodeChildren ) : VNode ;
32
+ ( tag : AsyncComponent < any , any , any , any > , data ?: VNodeData , children ?: VNodeChildren ) : VNode ;
29
33
}
30
34
31
- interface AnyVue extends Vue < any , any , any > {
32
- }
35
+ export interface AnyVue extends Vue < any , any , any , any > { }
36
+
37
+ export interface MinVue extends Vue < object , object , object , object > { }
33
38
34
- export interface Vue < Data , Methods , Computed > {
39
+ export interface Vue < Data , Methods , Computed , Props > {
35
40
$data : Data ;
36
41
readonly $el : HTMLElement ;
37
- readonly $options : ComponentOptions < Data , Methods , Computed > ;
42
+ readonly $options : ComponentOptions < Data , Methods , Computed , Props > ;
38
43
readonly $parent : AnyVue ;
39
44
readonly $root : AnyVue ;
40
45
readonly $children : AnyVue [ ] ;
41
46
readonly $refs : { [ key : string ] : AnyVue | Element | AnyVue [ ] | Element [ ] } ;
42
47
readonly $slots : { [ key : string ] : VNode [ ] } ;
43
48
readonly $scopedSlots : { [ key : string ] : ScopedSlot } ;
44
49
readonly $isServer : boolean ;
45
- readonly $props : any ;
50
+ readonly $props : Props ;
46
51
47
52
$mount ( elementOrSelector ?: Element | String , hydrating ?: boolean ) : this;
48
53
$forceUpdate ( ) : void ;
@@ -68,10 +73,19 @@ export interface Vue<Data, Methods, Computed> {
68
73
$createElement : CreateElement ;
69
74
}
70
75
76
+ export type CombinedVueInstance < Data , Methods , Computed , Props > = Data & Methods & Computed & Props & Vue < Data , Methods , Computed , Props >
77
+ export type ExtendedVue < Constructor extends VueConstructor , Data , Methods , Computed , Props > =
78
+ ( new ( ...args : any [ ] ) => CombinedVueInstance < Data , Methods , Computed , Props > ) &
79
+ Constructor ;
80
+
71
81
export interface VueConstructor {
72
- new < Data , Methods , Computed > ( options ?: ComponentOptions < Data , Methods & ThisType < Data & Methods & Computed > , Computed > & ThisType < Data & Methods & Computed > ) : Data & Methods & Computed & Vue < Data , Methods , Computed > ;
82
+ new < Data , Methods , Computed , PropNames extends string = never > ( options ?: ThisTypedComponentOptionsWithArrayProps < Data , Methods , Computed , PropNames > ) : CombinedVueInstance < Data , Methods , Computed , Record < PropNames , any > > ;
83
+ new < Data , Methods , Computed , Props extends Record < string , PropValidator > > ( options ?: ThisTypedComponentOptionsWithRecordProps < Data , Methods , Computed , Props > ) : CombinedVueInstance < Data , Methods , Computed , Record < keyof Props , any > > ;
84
+
85
+ extend < VC extends VueConstructor , PropNames extends string = never > ( this : VC , options : FunctionalComponentOptions < PropNames , Record < PropNames , any > > ) : ExtendedVue < VC , object , object , object , Record < PropNames , any > > ;
86
+ extend < VC extends VueConstructor , Data , Methods , Computed , PropNames extends string = never > ( this : VC , options : ThisTypedComponentOptionsWithArrayProps < Data , Methods , Computed , PropNames > ) : ExtendedVue < VC , Data , Methods , Computed , Record < PropNames , any > > ;
87
+ extend < VC extends VueConstructor , Data , Methods , Computed , Props extends Record < string , PropValidator > > ( this : VC , options ?: ThisTypedComponentOptionsWithRecordProps < Data , Methods , Computed , Props > ) : ExtendedVue < VC , Data , Methods , Computed , Record < keyof Props , any > > ;
73
88
74
- extend < V , Data , Methods , Computed > ( this : V , options : ComponentOptions < Data , Methods , Computed > | FunctionalComponentOptions ) : ( ( ...args : any [ ] ) => Vue < Data , Methods , Computed > ) & V ;
75
89
nextTick ( callback : ( ) => void , context ?: any [ ] ) : void ;
76
90
nextTick ( ) : Promise < void >
77
91
set < T > ( object : Object , key : string , value : T ) : T ;
@@ -83,10 +97,18 @@ export interface VueConstructor {
83
97
definition ?: DirectiveOptions | DirectiveFunction
84
98
) : DirectiveOptions ;
85
99
filter ( id : string , definition ?: Function ) : Function ;
86
- component ( id : string , definition ?: Component | AsyncComponent ) : typeof Vue ;
100
+
101
+ component ( id : string ) : VueConstructor ;
102
+ component < VC extends VueConstructor > ( id : string , constructor : VC ) : VC ;
103
+ component < VC extends VueConstructor , Data , Methods , Computed , PropNames extends string = never > ( this : VC , id : string , definition : AsyncComponent < Data , Methods , Computed , PropNames > ) : ExtendedVue < VC , Data , Methods , Computed , Record < PropNames , any > > ;
104
+ component < VC extends VueConstructor , PropNames extends string = never > ( this : VC , id : string , definition : FunctionalComponentOptions < PropNames , Record < PropNames , any > > ) : ExtendedVue < VC , { } , { } , { } , Record < PropNames , any > > ;
105
+ component < VC extends VueConstructor , Data , Methods , Computed , PropNames extends string = never > ( this : VC , id : string , definition : ThisTypedComponentOptionsWithArrayProps < Data , Methods , Computed , PropNames > ) : ExtendedVue < VC , Data , Methods , Computed , Record < PropNames , any > > ;
106
+ component < VC extends VueConstructor , Data , Methods , Computed , Props extends Record < string , PropValidator > > ( this : VC , id : string , definition ?: ThisTypedComponentOptionsWithRecordProps < Data , Methods , Computed , Props > ) : ExtendedVue < VC , Data , Methods , Computed , Record < keyof Props , any > > ;
107
+ //component<VC extends VueConstructor, Data, Methods, Computed, PropNames extends string = never>(this: VC, id: string, definition: Component<Data, Methods, Computed, PropNames>): ExtendedVue<VC, Data, Methods, Computed, Record<PropNames, any>>;
108
+ //component<Data, Methods, Computed, Props>(id: string, definition: Component<Data, Methods, Computed, Props> | AsyncComponent<Data, Methods, Computed, Props>): typeof Vue;
87
109
88
110
use < T > ( plugin : PluginObject < T > | PluginFunction < T > , options ?: T ) : void ;
89
- mixin ( mixin : typeof Vue | ComponentOptions < any , any , any > ) : void ;
111
+ mixin ( mixin : typeof Vue | ComponentOptions < any , any , any , any > ) : void ;
90
112
compile ( template : string ) : {
91
113
render ( createElement : typeof Vue . prototype . $createElement ) : VNode ;
92
114
staticRenderFns : ( ( ) => VNode ) [ ] ;
0 commit comments