@@ -850,6 +850,17 @@ Object: {
850850
851851 // $ExpectType null
852852 obj1 . concat ( obj2 . default ( null ) ) . getDefault ( ) ;
853+
854+ const optionalNonDefaultedObj = object ( {
855+ nested : object ( {
856+ h : number ( ) . required ( ) ,
857+ } )
858+ . default ( undefined )
859+ . optional ( ) ,
860+ } ) ;
861+
862+ // $ExpectType { h: number; } | undefined
863+ optionalNonDefaultedObj . cast ( { } ) . nested ;
853864 }
854865
855866 SchemaOfDate: {
@@ -959,13 +970,13 @@ Object: {
959970}
960971
961972Conditions: {
962- // $ExpectType StringSchema<string , AnyObject, undefined, ""> | NumberSchema<number | undefined , AnyObject, undefined, "">
973+ // $ExpectType NumberSchema<number | undefined , AnyObject, undefined, ""> | StringSchema<string , AnyObject, undefined, "">
963974 string ( ) . when ( 'foo' , ( [ foo ] , schema ) => ( foo ? schema . required ( ) : number ( ) ) ) ;
964975
965976 // $ExpectType StringSchema<string | undefined, AnyObject, undefined, "">
966977 string ( ) . when ( 'foo' , ( [ foo ] , schema ) => ( foo ? schema . required ( ) : schema ) ) ;
967978
968- // $ExpectType StringSchema<string , AnyObject, undefined, ""> | NumberSchema<number | undefined , AnyObject, undefined, "">
979+ // $ExpectType NumberSchema<number | undefined , AnyObject, undefined, ""> | StringSchema<string , AnyObject, undefined, "">
969980 string ( ) . when ( 'foo' , {
970981 is : true ,
971982 then : ( ) => number ( ) ,
0 commit comments