File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,8 @@ type BindFromProps<Props> = {
20
20
| ( ( ...args : Parameters < Props [ K ] > ) => ReturnType < Props [ K ] > )
21
21
// Edge-case: allow to pass an event listener without any parameters (e.g. onClick: () => ...)
22
22
| ( ( ) => ReturnType < Props [ K ] > )
23
+ // Edge-case: allow to pass an Store, which contains a function
24
+ | Store < Props [ K ] >
23
25
: Store < Props [ K ] > | Props [ K ] ;
24
26
} ;
25
27
Original file line number Diff line number Diff line change @@ -182,6 +182,50 @@ import { expectType } from 'tsd';
182
182
expectType < React . FC > ( ReflectedInput ) ;
183
183
}
184
184
185
+ // should allow store with a function as a callback value
186
+ {
187
+ const Input : React . FC < {
188
+ value : string ;
189
+ onChange : ( newValue : string ) => void ;
190
+ } > = ( ) => null ;
191
+ const $changed = createStore < ( newValue : string ) => void > ( ( ) => { } ) ;
192
+
193
+ const ReflectedInput = reflect ( {
194
+ view : Input ,
195
+ bind : {
196
+ value : 'plain string' ,
197
+ onChange : $changed ,
198
+ } ,
199
+ } ) ;
200
+
201
+ expectType < React . FC > ( ReflectedInput ) ;
202
+ }
203
+
204
+ function localize < T extends 'b' > ( value : T ) : { lol : boolean } ;
205
+ function localize < T extends 'a' > ( value : T ) : { kek : boolean } ;
206
+ function localize ( value : string ) : unknown {
207
+ return value ;
208
+ }
209
+
210
+ // should allow store with generics
211
+ {
212
+ const Input : React . FC < {
213
+ value : string ;
214
+ onChange : typeof localize ;
215
+ } > = ( ) => null ;
216
+ const $changed = createStore < typeof localize > ( localize ) ;
217
+
218
+ const ReflectedInput = reflect ( {
219
+ view : Input ,
220
+ bind : {
221
+ value : 'plain string' ,
222
+ onChange : $changed ,
223
+ } ,
224
+ } ) ;
225
+
226
+ expectType < React . FC > ( ReflectedInput ) ;
227
+ }
228
+
185
229
// should support useUnit configuration
186
230
{
187
231
const Input : React . FC < {
You can’t perform that action at this time.
0 commit comments