File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import type { NonEmptyArray } from '../../types/arrays.js' ;
12import type { InferPredicatesReturnType , TypePredicateFn } from '../../types/functions.js' ;
23import type { IntersectionOf } from '../../types/utils.js' ;
34
45/**
56 * All predicates must pass
67 */
7- export const allOf = < Predicates extends TypePredicateFn < unknown > [ ] > (
8+ export const allOf = < Predicates extends NonEmptyArray < TypePredicateFn < unknown > > > (
89 ...predicates : Predicates
910) : TypePredicateFn < IntersectionOf < InferPredicatesReturnType < Predicates > > > => {
1011 if ( ! predicates . length ) {
Original file line number Diff line number Diff line change 1+ import type { NonEmptyArray } from '../../types/arrays.js' ;
12import type { InferPredicatesReturnType , TypePredicateFn } from '../../types/functions.js' ;
23import type { UnionOf } from '../../types/utils.js' ;
34
45/**
56 * Any predicate can pass
67 */
7- export const anyOf = < Predicates extends TypePredicateFn < unknown > [ ] > (
8+ export const anyOf = < Predicates extends NonEmptyArray < TypePredicateFn < unknown > > > (
89 ...predicates : Predicates
910) : TypePredicateFn < UnionOf < InferPredicatesReturnType < Predicates > > > => {
1011 if ( ! predicates . length ) {
Original file line number Diff line number Diff line change @@ -7,7 +7,10 @@ import { isString } from '../../../src/predicate/isString.js';
77
88describe ( 'allOf()' , ( ) => {
99 it ( 'Requires one or more type predicate function' , ( ) => {
10- expect ( ( ) => allOf ( ) ) . toThrow ( ) ;
10+ expect ( ( ) => {
11+ // @ts -expect-error testing missing arguments
12+ allOf ( ) ;
13+ } ) . toThrow ( ) ;
1114 } ) ;
1215
1316 it ( 'Returns a type predicate function' , ( ) => {
Original file line number Diff line number Diff line change @@ -4,7 +4,10 @@ import { anyOf } from '../../../src/predicate/factory/anyOf.js';
44
55describe ( 'anyOf()' , ( ) => {
66 it ( 'Requires one or more type predicate function' , ( ) => {
7- expect ( ( ) => anyOf ( ) ) . toThrow ( ) ;
7+ expect ( ( ) => {
8+ // @ts -expect-error testing missing arguments
9+ return anyOf ( ) ;
10+ } ) . toThrow ( ) ;
811 } ) ;
912
1013 it ( 'Returns a type predicate function' , ( ) => {
You can’t perform that action at this time.
0 commit comments