File tree 2 files changed +22
-8
lines changed
2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -41,14 +41,18 @@ interface MountingOptions {
41
41
stubs ?: Record < string , any >
42
42
}
43
43
44
- export function mount < T extends any > (
45
- originalComponent : any ,
44
+ export function mount < TestedComponent extends ComponentPublicInstance > (
45
+ originalComponent : new ( ) => TestedComponent ,
46
+ options ?: MountingOptions
47
+ ) : VueWrapper < TestedComponent >
48
+ export function mount (
49
+ originalComponent : Component ,
46
50
options ?: MountingOptions
47
51
) : VueWrapper < any >
48
- export function mount < T extends ComponentPublicInstance > (
49
- originalComponent : new ( ) => T ,
52
+ export function mount (
53
+ originalComponent : any ,
50
54
options ?: MountingOptions
51
- ) : VueWrapper < T > {
55
+ ) : VueWrapper < any > {
52
56
const component = { ...originalComponent }
53
57
54
58
// Reset the document.body
@@ -158,5 +162,5 @@ export function mount<T extends ComponentPublicInstance>(
158
162
// mount the app!
159
163
const app = vm . mount ( el )
160
164
161
- return createWrapper < T > ( app , events , setProps )
165
+ return createWrapper ( app , events , setProps )
162
166
}
Original file line number Diff line number Diff line change @@ -9,5 +9,15 @@ const App = defineComponent({
9
9
template : ''
10
10
} )
11
11
12
- const wrapper = mount ( App )
13
- expectType < any > ( wrapper . vm . a ) // should be string
12
+ let wrapper = mount ( App )
13
+ expectType < string > ( wrapper . vm . a )
14
+
15
+ const AppWithoutDefine = {
16
+ props : {
17
+ a : String
18
+ } ,
19
+ template : ''
20
+ }
21
+
22
+ wrapper = mount ( AppWithoutDefine )
23
+ expectType < string > ( wrapper . vm . a )
You can’t perform that action at this time.
0 commit comments