Skip to content

Commit

Permalink
Improve Ramda #props. (flow-typed#1503)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewSouthpaw authored and gantoine committed Nov 9, 2017
1 parent f6f8972 commit 6fd2ad7
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 72 deletions.
63 changes: 0 additions & 63 deletions cli/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ ajv@^4.7.0:
co "^4.6.0"
json-stable-stringify "^1.0.1"

ajv@^4.9.1:
version "4.11.8"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536"
dependencies:
co "^4.6.0"
json-stable-stringify "^1.0.1"

ajv@^5.2.0:
version "5.2.2"
resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.2.2.tgz#47c68d69e86f5d953103b0074a9430dc63da5e39"
Expand Down Expand Up @@ -927,10 +920,6 @@ caseless@~0.11.0:
version "0.11.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.11.0.tgz#715b96ea9841593cc33067923f5ec60ebda4f7d7"

caseless@~0.12.0:
version "0.12.0"
resolved "https://registry.yarnpkg.com/caseless/-/caseless-0.12.0.tgz#1b681c21ff84033c826543090689420d187151dc"

center-align@^0.1.1:
version "0.1.3"
resolved "https://registry.yarnpkg.com/center-align/-/center-align-0.1.3.tgz#aa0d32629b6ee972200411cbd4461c907bc2b7ad"
Expand Down Expand Up @@ -1673,10 +1662,6 @@ handlebars@^4.0.3:
optionalDependencies:
uglify-js "^2.6"

har-schema@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/har-schema/-/har-schema-1.0.5.tgz#d263135f43307c02c602afc8fe95970c0151369e"

har-validator@~2.0.6:
version "2.0.6"
resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-2.0.6.tgz#cdcbc08188265ad119b6a5a7c8ab70eecfb5d27d"
Expand All @@ -1686,13 +1671,6 @@ har-validator@~2.0.6:
is-my-json-valid "^2.12.4"
pinkie-promise "^2.0.0"

har-validator@~4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/har-validator/-/har-validator-4.2.1.tgz#33481d0f1bbff600dd203d75812a6a5fba002e2a"
dependencies:
ajv "^4.9.1"
har-schema "^1.0.5"

has-ansi@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91"
Expand Down Expand Up @@ -2780,10 +2758,6 @@ path-type@^1.0.0:
pify "^2.0.0"
pinkie-promise "^2.0.0"

performance-now@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-0.2.0.tgz#33ef30c5c77d4ea21c5a53869d91b56d8f2555e5"

pify@^2.0.0, pify@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
Expand Down Expand Up @@ -2858,10 +2832,6 @@ qs@~6.3.0:
version "6.3.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.3.0.tgz#f403b264f23bc01228c74131b407f18d5ea5d442"

qs@~6.4.0:
version "6.4.0"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.4.0.tgz#13e26d28ad6b0ffaa91312cd3bf708ed351e7233"

randomatic@^1.1.3:
version "1.1.6"
resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-1.1.6.tgz#110dcabff397e9dcff7c0789ccc0a49adf1ec5bb"
Expand Down Expand Up @@ -3027,33 +2997,6 @@ request@^2.79.0:
tunnel-agent "~0.4.1"
uuid "^3.0.0"

request@^2.81.0:
version "2.81.0"
resolved "https://registry.yarnpkg.com/request/-/request-2.81.0.tgz#c6928946a0e06c5f8d6f8a9333469ffda46298a0"
dependencies:
aws-sign2 "~0.6.0"
aws4 "^1.2.1"
caseless "~0.12.0"
combined-stream "~1.0.5"
extend "~3.0.0"
forever-agent "~0.6.1"
form-data "~2.1.1"
har-validator "~4.2.1"
hawk "~3.1.3"
http-signature "~1.1.0"
is-typedarray "~1.0.0"
isstream "~0.1.2"
json-stringify-safe "~5.0.1"
mime-types "~2.1.7"
oauth-sign "~0.8.1"
performance-now "^0.2.0"
qs "~6.4.0"
safe-buffer "^5.0.1"
stringstream "~0.0.4"
tough-cookie "~2.3.0"
tunnel-agent "^0.6.0"
uuid "^3.0.0"

require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
Expand Down Expand Up @@ -3433,12 +3376,6 @@ tryit@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/tryit/-/tryit-1.0.3.tgz#393be730a9446fd1ead6da59a014308f36c289cb"

tunnel-agent@^0.6.0:
version "0.6.0"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
dependencies:
safe-buffer "^5.0.1"

tunnel-agent@~0.4.1:
version "0.4.3"
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.4.3.tgz#6373db76909fe570e08d73583365ed828a74eeeb"
Expand Down
12 changes: 6 additions & 6 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 @@ -1523,14 +1523,14 @@ declare module ramda {

declare function keysIn(o: Object): Array<string>;

declare function props<T, O: { [k: string]: T }>(
keys: Array<$Keys<O>>,
declare function props<T: string, O>(
keys: Array<T>,
...rest: Array<void>
): (o: O) => Array<?T>;
declare function props<T, O: { [k: string]: T }>(
keys: Array<$Keys<O>>,
): (o: O) => Array<$ElementType<O, T>>;
declare function props<T: string, O>(
keys: Array<T>,
o: O
): Array<?T>;
): Array<$ElementType<O, T>>;

// TODO set

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,31 @@ const fav = favoriteWithDefault(alice);
const nameWithDefault = _.propOr("Ramda", "name");
const nm: number | string = nameWithDefault(alice);

const pss: Array<?number | boolean> = _.props(["x", "y"], { x: true, y: 2 });
//$ExpectError
const pssE: Array<?number | boolean> = _.props(["d", "y"], { x: true, y: 2 });
const pss1: Array<number | boolean> = _.props(["x", "y"], {
x: true,
y: 2,
z: "foo"
});
const pss2: Array<number | boolean> = _.props(
["x", "y"],
({ x: true, y: 2, z: "foo" }: { x: boolean, y: number })
);
const pss3: Array<number> = _.props(["y"], { x: true, y: 2, z: "foo" });
const pss4: Array<number> = _.props(["y"], ({ y: 2 }: { [string]: number }));
//$ExpectError -- wrong key
const pssE1: Array<number | boolean> = _.props(["d", "y"], {
x: true,
y: 2,
z: "foo"
});
//$ExpectError -- wrong type
const pssE2: Array<string | boolean> = _.props(["x", "y"], {
x: true,
y: 2,
z: "foo"
});
//$ExpectError -- wrong type on indexer value
const pssE3: Array<string> = _.props(["y"], ({ y: 2 }: { [string]: number }));

const top: Array<["a" | "b" | "c", number]> = _.toPairs({ a: 1, b: 2, c: 3 });

Expand Down

0 comments on commit 6fd2ad7

Please sign in to comment.