Support infinitary functions in cond type type def

This commit is contained in:
Alex Deas
2018-12-06 22:10:03 +00:00
parent 5d4421790f
commit 8cfbfbf4be
2 changed files with 5 additions and 2 deletions

View File

@@ -776,7 +776,8 @@ declare namespace R {
* point fn returns the result of applying its arguments to the corresponding transformer. If none of the predicates
* matches, fn returns undefined.
*/
cond<A, B>(fns: ReadonlyArray<[SafePred<A>, (a: A) => B]>): (a: A) => B;
cond(fns: ReadonlyArray<[Pred, (...a: any[]) => any]>): (...a: any[]) => any;
cond<A, B>(fns: ReadonlyArray<[SafePred<A>, (...a: A[]) => B]>): (...a: A[]) => B;
/**
* Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.

View File

@@ -1312,13 +1312,15 @@ type Pair = KeyValuePair<string, number>;
]);
f(0); // $ExpectType string
f(""); // $ExpectError
f(1, 2); // $ExpectType string
const g = R.cond([
[x => x === 0, () => "a"],
[(a, b) => a === b, () => "a"],
[() => true, () => "b"],
]);
g(0);
g("");
g(1, "");
};
() => {