Skip to content

Commit 2276e74

Browse files
authored
Merge pull request #93 from andnp/SimplePredicate
feat: remove IsAny case from Predicate
2 parents 2e56c72 + 6ed315d commit 2276e74

File tree

3 files changed

+1
-19
lines changed

3 files changed

+1
-19
lines changed

README.md

-9
Original file line numberDiff line numberDiff line change
@@ -660,15 +660,6 @@ test('Can build a predicate function with single known argument type', t => {
660660
assert<PredFunc, expected>(t);
661661
});
662662

663-
test('Can build a predicate function with unknown argument types', t => {
664-
type PredFunc = Predicate;
665-
type works = (arg1: string, arg2: number) => boolean;
666-
type expected = (...args: any[]) => boolean;
667-
668-
assert<PredFunc, works>(t);
669-
assert<PredFunc, expected>(t);
670-
});
671-
672663
```
673664

674665
## Strings

src/types/functions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export type ConstructorFunction<T extends object> = new (...args: any[]) => T;
88
/**
99
* This is a function that takes some args and returns a boolean
1010
*/
11-
export type Predicate<A = any> = If<IsAny<A>, (...args: any[]) => boolean, (arg: A) => boolean>;
11+
export type Predicate<A = any> = (arg: A) => boolean;
1212
/**
1313
* Concisely and cleanly define an arbitrary function.
1414
* Useful when designing many api's that don't care what function they take in, they just need to know what it returns.

test/functions/Predicate.test.ts

-9
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,3 @@ test('Can build a predicate function with single known argument type', t => {
99

1010
assert<PredFunc, expected>(t);
1111
});
12-
13-
test('Can build a predicate function with unknown argument types', t => {
14-
type PredFunc = Predicate;
15-
type works = (arg1: string, arg2: number) => boolean;
16-
type expected = (...args: any[]) => boolean;
17-
18-
assert<PredFunc, works>(t);
19-
assert<PredFunc, expected>(t);
20-
});

0 commit comments

Comments
 (0)