Skip to content

Commit

Permalink
apply $ElementType workaround to other ramda propEq arities (flow-typ…
Browse files Browse the repository at this point in the history
  • Loading branch information
LoganBarnett authored and gantoine committed Nov 10, 2017
1 parent 56da885 commit eab33c9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions definitions/npm/ramda_v0.x.x/flow_v0.49.x-/ramda_v0.x.x.js
Original file line number Diff line number Diff line change
Expand Up @@ -1041,11 +1041,11 @@ declare module ramda {
// siguatures should go from smallest arity to largest arity.
declare type PropEq = (<T>(
prop: $Keys<T>
) => ((val: $ElementType<T, $Keys<T>>) => (obj: T) => boolean) &
) => ((val: $Ramda_ElementType<T, $Keys<T>>) => (obj: T) => boolean) &
((val: $ElementType<T, $Keys<T>>, obj: T) => boolean)) &
(<T>(
prop: $Keys<T>,
val: $ElementType<T, $Keys<T>>
val: $Ramda_ElementType<T, $Keys<T>>
) => (obj: T) => boolean) &
(<T>(
prop: $Keys<T>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,22 @@ const pathEqObj2: boolean = _.pathEq(["hello"])(1)(obj);
type PropEqFoo = { bar: number };
const propEqFoo: PropEqFoo = { bar: 2 };

const propEqResult1: boolean = _.propEq("bar", 1, propEqFoo);
const propEqResult1a: boolean = _.propEq("bar", 1, propEqFoo);
// Test curried versions.
const propEqResult1a: boolean = _.propEq("bar")(1)(propEqFoo);
const propEqResult1b: boolean = _.propEq("bar")(1, propEqFoo);
const propEqResult1c: boolean = _.propEq("bar", 1)(propEqFoo);
const propEqResult1b: boolean = _.propEq("bar")(1)(propEqFoo);
const propEqResult1c: boolean = _.propEq("bar")(1, propEqFoo);
const propEqResult1d: boolean = _.propEq("bar", 1)(propEqFoo);

// The type compared should be the type of the property.
// $ExpectError
const propEqResult2: boolean = _.propEq("bar", "wrong", propEqFoo);
const propEqResult2a: boolean = _.propEq("bar", "wrong", propEqFoo);
// Test the same comparison param against the various arities.
// $ExpectError
const propEqResult2b: boolean = _.propEq("bar")("wrong")(propEqFoo);
// $ExpectError
const propEqResult2c: boolean = _.propEq("bar")("wrong", propEqFoo);
// $ExpectError
const propEqResult2d: boolean = _.propEq("bar", "wrong")(propEqFoo);

// The property name must be a property on the object supplied.
// $ExpectError
Expand Down

0 comments on commit eab33c9

Please sign in to comment.