File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -997,6 +997,17 @@ Deno.test("isOneOf<T>", async (t) => {
997997 assertType < Equal < typeof a , number | string | boolean > > ( true ) ;
998998 }
999999 } ) ;
1000+ await t . step ( "returns proper type predicate (#49)" , ( ) => {
1001+ const isFoo = isObjectOf ( { foo : isString } ) ;
1002+ const isBar = isObjectOf ( { foo : isString , bar : isNumber } ) ;
1003+ type Foo = PredicateType < typeof isFoo > ;
1004+ type Bar = PredicateType < typeof isBar > ;
1005+ const preds = [ isFoo , isBar ] ;
1006+ const a : unknown = [ 0 , "a" , true ] ;
1007+ if ( isOneOf ( preds ) ( a ) ) {
1008+ assertType < Equal < typeof a , Foo | Bar > > ( true ) ;
1009+ }
1010+ } ) ;
10001011 await t . step ( "returns true on one of T" , ( ) => {
10011012 const preds = [ isNumber , isString , isBoolean ] ;
10021013 assertEquals ( isOneOf ( preds ) ( 0 ) , true ) ;
You can’t perform that action at this time.
0 commit comments