@@ -17,7 +17,12 @@ import {
17
17
ComponentPropsOptions ,
18
18
AppConfig ,
19
19
VNodeProps ,
20
- ComponentOptionsMixin
20
+ ComponentOptionsMixin ,
21
+ DefineComponent ,
22
+ MethodOptions ,
23
+ AllowedComponentProps ,
24
+ ComponentCustomProps ,
25
+ ExtractDefaultPropTypes
21
26
} from 'vue'
22
27
23
28
import { config } from './config'
@@ -34,18 +39,17 @@ import {
34
39
} from './constants'
35
40
import { stubComponents } from './stubs'
36
41
42
+ // NOTE this should come from `vue`
43
+ type PublicProps = VNodeProps & AllowedComponentProps & ComponentCustomProps
44
+
37
45
type Slot = VNode | string | { render : Function } | Function | Component
38
46
39
47
type SlotDictionary = {
40
48
[ key : string ] : Slot
41
49
}
42
50
43
51
interface MountingOptions < Props , Data = { } > {
44
- data ?: ( ) => { } extends Data
45
- ? never
46
- : Data extends object
47
- ? Partial < Data >
48
- : never
52
+ data ?: ( ) => { } extends Data ? any : Data extends object ? Partial < Data > : any
49
53
props ?: Props
50
54
/** @deprecated */
51
55
propsData ?: Props
@@ -78,10 +82,53 @@ export function mount<
78
82
) : VueWrapper < ComponentPublicInstance < Props > >
79
83
80
84
// Component declared with defineComponent
81
- export function mount < TestedComponent extends ComponentPublicInstance > (
82
- originalComponent : { new ( ) : TestedComponent } & Component ,
83
- options ?: MountingOptions < TestedComponent [ '$props' ] , TestedComponent [ '$data' ] >
84
- ) : VueWrapper < TestedComponent >
85
+ export function mount <
86
+ PropsOrPropOptions = { } ,
87
+ RawBindings = { } ,
88
+ D = { } ,
89
+ C extends ComputedOptions = ComputedOptions ,
90
+ M extends MethodOptions = MethodOptions ,
91
+ Mixin extends ComponentOptionsMixin = ComponentOptionsMixin ,
92
+ Extends extends ComponentOptionsMixin = ComponentOptionsMixin ,
93
+ E extends EmitsOptions = Record < string , any > ,
94
+ EE extends string = string ,
95
+ PP = PublicProps ,
96
+ Props = Readonly < ExtractPropTypes < PropsOrPropOptions > > ,
97
+ Defaults = ExtractDefaultPropTypes < PropsOrPropOptions >
98
+ > (
99
+ component : DefineComponent <
100
+ PropsOrPropOptions ,
101
+ RawBindings ,
102
+ D ,
103
+ C ,
104
+ M ,
105
+ Mixin ,
106
+ Extends ,
107
+ E ,
108
+ EE ,
109
+ PP ,
110
+ Props ,
111
+ Defaults
112
+ > ,
113
+ options ?: MountingOptions < Props , D >
114
+ ) : VueWrapper <
115
+ InstanceType <
116
+ DefineComponent <
117
+ PropsOrPropOptions ,
118
+ RawBindings ,
119
+ D ,
120
+ C ,
121
+ M ,
122
+ Mixin ,
123
+ Extends ,
124
+ E ,
125
+ EE ,
126
+ PP ,
127
+ Props ,
128
+ Defaults
129
+ >
130
+ >
131
+ >
85
132
86
133
// Component declared with no props
87
134
export function mount <
0 commit comments