@@ -1414,6 +1414,8 @@ describe('slots', () => {
14141414 slots : Object as SlotsType < {
14151415 default : { foo : string ; bar : number }
14161416 optional ?: { data : string }
1417+ undefinedScope : undefined | { data : string }
1418+ optionalUndefinedScope ?: undefined | { data : string }
14171419 } > ,
14181420 setup ( props , { slots } ) {
14191421 expectType < ( scope : { foo : string ; bar : number } ) => VNode [ ] > (
@@ -1429,6 +1431,33 @@ describe('slots', () => {
14291431 slots . optional ( { data : 'foo' } )
14301432 slots . optional ?.( { data : 'foo' } )
14311433
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+
14321461 expectType < typeof slots | undefined > ( new comp1 ( ) . $slots )
14331462 }
14341463 } )
0 commit comments