Skip to content

Commit

Permalink
Merge pull request #93 from andnp/SimplePredicate
Browse files Browse the repository at this point in the history
feat: remove IsAny case from Predicate
  • Loading branch information
andnp authored Mar 12, 2019
2 parents 2e56c72 + 6ed315d commit 2276e74
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 19 deletions.
9 changes: 0 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -660,15 +660,6 @@ test('Can build a predicate function with single known argument type', t => {
assert<PredFunc, expected>(t);
});

test('Can build a predicate function with unknown argument types', t => {
type PredFunc = Predicate;
type works = (arg1: string, arg2: number) => boolean;
type expected = (...args: any[]) => boolean;

assert<PredFunc, works>(t);
assert<PredFunc, expected>(t);
});

```

## Strings
Expand Down
2 changes: 1 addition & 1 deletion src/types/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export type ConstructorFunction<T extends object> = new (...args: any[]) => T;
/**
* This is a function that takes some args and returns a boolean
*/
export type Predicate<A = any> = If<IsAny<A>, (...args: any[]) => boolean, (arg: A) => boolean>;
export type Predicate<A = any> = (arg: A) => boolean;
/**
* Concisely and cleanly define an arbitrary function.
* Useful when designing many api's that don't care what function they take in, they just need to know what it returns.
Expand Down
9 changes: 0 additions & 9 deletions test/functions/Predicate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,3 @@ test('Can build a predicate function with single known argument type', t => {

assert<PredFunc, expected>(t);
});

test('Can build a predicate function with unknown argument types', t => {
type PredFunc = Predicate;
type works = (arg1: string, arg2: number) => boolean;
type expected = (...args: any[]) => boolean;

assert<PredFunc, works>(t);
assert<PredFunc, expected>(t);
});

0 comments on commit 2276e74

Please sign in to comment.