@@ -1414,6 +1414,8 @@ describe('slots', () => {
1414
1414
slots : Object as SlotsType < {
1415
1415
default : { foo : string ; bar : number }
1416
1416
optional ?: { data : string }
1417
+ undefinedScope : undefined | { data : string }
1418
+ optionalUndefinedScope ?: undefined | { data : string }
1417
1419
} > ,
1418
1420
setup ( props , { slots } ) {
1419
1421
expectType < ( scope : { foo : string ; bar : number } ) => VNode [ ] > (
@@ -1429,6 +1431,33 @@ describe('slots', () => {
1429
1431
slots . optional ( { data : 'foo' } )
1430
1432
slots . optional ?.( { data : 'foo' } )
1431
1433
1434
+ expectType < {
1435
+ ( ) : VNode [ ]
1436
+ ( scope : undefined | { data : string } ) : VNode [ ]
1437
+ } > ( slots . undefinedScope )
1438
+
1439
+ expectType <
1440
+ | { ( ) : VNode [ ] ; ( scope : undefined | { data : string } ) : VNode [ ] }
1441
+ | undefined
1442
+ > ( slots . optionalUndefinedScope )
1443
+
1444
+ slots . default ( { foo : 'foo' , bar : 1 } )
1445
+ // @ts -expect-error it's optional
1446
+ slots . optional ( { data : 'foo' } )
1447
+ slots . optional ?.( { data : 'foo' } )
1448
+ slots . undefinedScope ( )
1449
+ slots . undefinedScope ( undefined )
1450
+ // @ts -expect-error
1451
+ slots . undefinedScope ( 'foo' )
1452
+
1453
+ slots . optionalUndefinedScope ?.( )
1454
+ slots . optionalUndefinedScope ?.( undefined )
1455
+ slots . optionalUndefinedScope ?.( { data : 'foo' } )
1456
+ // @ts -expect-error
1457
+ slots . optionalUndefinedScope ( )
1458
+ // @ts -expect-error
1459
+ slots . optionalUndefinedScope ?.( 'foo' )
1460
+
1432
1461
expectType < typeof slots | undefined > ( new comp1 ( ) . $slots )
1433
1462
}
1434
1463
} )
0 commit comments