File tree Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Expand file tree Collapse file tree 2 files changed +42
-4
lines changed Original file line number Diff line number Diff line change @@ -75,7 +75,11 @@ export function createComponent<RawBindings>(
75
75
) : VueProxy < never , RawBindings > ;
76
76
// overload 2: object format with object props declaration
77
77
// see `ExtractPropTypes` in ./componentProps.ts
78
- export function createComponent < Props , RawBindings = Data , PropsOptions = ComponentPropsOptions > (
78
+ export function createComponent <
79
+ Props ,
80
+ RawBindings = Data ,
81
+ PropsOptions extends ComponentPropsOptions = ComponentPropsOptions
82
+ > (
79
83
// prettier-ignore
80
84
options : (
81
85
// prefer the provided Props, otherwise infer it from PropsOptions
Original file line number Diff line number Diff line change @@ -59,7 +59,7 @@ describe('createComponent', () => {
59
59
return ( ) => null ;
60
60
} ,
61
61
} ) ;
62
- new Vue ( App ) . $mount ( ) ;
62
+ new Vue ( App ) ;
63
63
expect . assertions ( 3 ) ;
64
64
} ) ;
65
65
@@ -79,7 +79,7 @@ describe('createComponent', () => {
79
79
return ( ) => null ;
80
80
} ,
81
81
} ) ;
82
- new Vue ( App ) . $mount ( ) ;
82
+ new Vue ( App ) ;
83
83
expect . assertions ( 3 ) ;
84
84
} ) ;
85
85
@@ -91,7 +91,41 @@ describe('createComponent', () => {
91
91
return ( ) => null ;
92
92
} ,
93
93
} ) ;
94
- new Vue ( App ) . $mount ( ) ;
94
+ new Vue ( App ) ;
95
+ expect . assertions ( 2 ) ;
96
+ } ) ;
97
+
98
+ it ( 'infer the required prop' , ( ) => {
99
+ const App = createComponent ( {
100
+ props : {
101
+ foo : {
102
+ type : String ,
103
+ required : true ,
104
+ } ,
105
+ bar : {
106
+ type : String ,
107
+ default : 'default' ,
108
+ } ,
109
+ zoo : {
110
+ type : String ,
111
+ required : false ,
112
+ } ,
113
+ } ,
114
+ propsData : {
115
+ foo : 'foo' ,
116
+ } ,
117
+ setup ( props ) {
118
+ type PropsType = typeof props ;
119
+ isSubType < { readonly foo : string ; readonly bar : string ; readonly zoo ?: string } , PropsType > (
120
+ true
121
+ ) ;
122
+ isSubType < PropsType , { readonly foo : string ; readonly bar : string ; readonly zoo ?: string } > (
123
+ true
124
+ ) ;
125
+ return ( ) => null ;
126
+ } ,
127
+ } ) ;
128
+ new Vue ( App ) ;
95
129
expect . assertions ( 2 ) ;
96
130
} ) ;
97
131
} ) ;
You can’t perform that action at this time.
0 commit comments