@@ -380,6 +380,7 @@ function localize(value: string): unknown {
380
380
type Props = { loading : boolean } ;
381
381
382
382
const mounted = createEvent ( ) ;
383
+ const unmounted = createEvent ( ) ;
383
384
384
385
const Foo : FC < Props > = ( props ) => < > </ > ;
385
386
@@ -390,7 +391,7 @@ function localize(value: string): unknown {
390
391
bind : {
391
392
loading : $loading ,
392
393
} ,
393
- hooks : { mounted } ,
394
+ hooks : { mounted, unmounted } ,
394
395
} ) ;
395
396
}
396
397
@@ -399,6 +400,7 @@ function localize(value: string): unknown {
399
400
type Props = { loading : boolean } ;
400
401
401
402
const mounted = createEvent < Props > ( ) ;
403
+ const unmounted = createEvent < Props > ( ) ;
402
404
403
405
const Foo : FC < Props > = ( props ) => < > </ > ;
404
406
@@ -409,19 +411,54 @@ function localize(value: string): unknown {
409
411
bind : {
410
412
loading : $loading ,
411
413
} ,
412
- hooks : { mounted } ,
414
+ hooks : { mounted, unmounted } ,
413
415
} ) ;
414
416
}
415
417
416
418
// should error if mounted event doesn't satisfy component props
417
419
{
418
420
const mounted = createEvent < { foo : string } > ( ) ;
421
+ const unmounted = createEvent < { foo : string } > ( ) ;
419
422
420
423
const Foo : FC < { bar : number } > = ( ) => null ;
421
424
422
425
const Bar = reflect ( {
423
426
view : Foo ,
424
427
// @ts -expect-error
425
- hooks : { mounted } ,
428
+ hooks : { mounted, unmounted } ,
429
+ } ) ;
430
+ }
431
+
432
+ // reflect supports partial match of mounted event and component props
433
+ {
434
+ const mounted = createEvent < { foo : string } > ( ) ;
435
+ const unmounted = createEvent < { foo : string } > ( ) ;
436
+
437
+ const Foo : FC < { foo : string ; bar : number } > = ( ) => null ;
438
+
439
+ const Bar = reflect ( {
440
+ view : Foo ,
441
+ bind : {
442
+ foo : 'foo' ,
443
+ bar : 42 ,
444
+ } ,
445
+ hooks : { mounted, unmounted } ,
446
+ } ) ;
447
+ }
448
+
449
+ // reflect supports partial match of mounted callback and component props
450
+ {
451
+ const mounted = ( args : { foo : string } ) => { } ;
452
+ const unmounted = ( args : { foo : string } ) => { } ;
453
+
454
+ const Foo : FC < { foo : string ; bar : number } > = ( ) => null ;
455
+
456
+ const Bar = reflect ( {
457
+ view : Foo ,
458
+ bind : {
459
+ foo : 'foo' ,
460
+ bar : 42 ,
461
+ } ,
462
+ hooks : { mounted, unmounted } ,
426
463
} ) ;
427
464
}
0 commit comments