From e7dd848801daa88e9f39981fe19fd4f969b84df0 Mon Sep 17 00:00:00 2001 From: Mike Deverell Date: Wed, 25 Sep 2019 17:11:26 -0400 Subject: [PATCH] [ramda] split tests to separate modules: 'join' - 'mean' (#38570) * move 'join' tests to separate file * move 'juxt' tests to separate file * move 'keys' tests to separate file * move 'keysIn' tests to separate file * move 'last' tests to separate file * move 'lastIndexOf' tests to separate file * move 'length' tests to separate file * move 'lens' tests to separate file * move 'lensIndex' tests to separate file * move 'lensProp' tests to separate file * move 'lt' tests to separate file * move 'lte' tests to separate file * move 'map' tests to separate file * move 'mapAccum' tests to separate file * move 'mapAccumRight' tests to separate file * move 'mapObjIndexed' tests to separate file * move 'mathMod' tests to separate file * move 'max' tests to separate file * move 'maxBy' tests to separate file * move 'mean' tests to separate file --- types/ramda/ramda-tests.ts | 240 ------------------------ types/ramda/test/join-tests.ts | 7 + types/ramda/test/juxt-tests.ts | 9 + types/ramda/test/keys-tests.ts | 8 + types/ramda/test/keysIn-tests.ts | 12 ++ types/ramda/test/last-tests.ts | 7 + types/ramda/test/lastIndexOf-tests.ts | 6 + types/ramda/test/length-tests.ts | 6 + types/ramda/test/lens-tests.ts | 30 +++ types/ramda/test/lensIndex-tests.ts | 7 + types/ramda/test/lensProp-tests.ts | 10 + types/ramda/test/lt-tests.ts | 8 + types/ramda/test/lte-tests.ts | 8 + types/ramda/test/map-tests.ts | 44 +++++ types/ramda/test/mapAccum-tests.ts | 13 ++ types/ramda/test/mapAccumRight-tests.ts | 13 ++ types/ramda/test/mapObjIndexed-tests.ts | 24 +++ types/ramda/test/mathMod-tests.ts | 13 ++ types/ramda/test/max-tests.ts | 6 + types/ramda/test/maxBy-tests.ts | 19 ++ types/ramda/test/mean-tests.ts | 6 + types/ramda/tsconfig.json | 22 ++- 22 files changed, 277 insertions(+), 241 deletions(-) create mode 100644 types/ramda/test/join-tests.ts create mode 100644 types/ramda/test/juxt-tests.ts create mode 100644 types/ramda/test/keys-tests.ts create mode 100644 types/ramda/test/keysIn-tests.ts create mode 100644 types/ramda/test/last-tests.ts create mode 100644 types/ramda/test/lastIndexOf-tests.ts create mode 100644 types/ramda/test/length-tests.ts create mode 100644 types/ramda/test/lens-tests.ts create mode 100644 types/ramda/test/lensIndex-tests.ts create mode 100644 types/ramda/test/lensProp-tests.ts create mode 100644 types/ramda/test/lt-tests.ts create mode 100644 types/ramda/test/lte-tests.ts create mode 100644 types/ramda/test/map-tests.ts create mode 100644 types/ramda/test/mapAccum-tests.ts create mode 100644 types/ramda/test/mapAccumRight-tests.ts create mode 100644 types/ramda/test/mapObjIndexed-tests.ts create mode 100644 types/ramda/test/mathMod-tests.ts create mode 100644 types/ramda/test/max-tests.ts create mode 100644 types/ramda/test/maxBy-tests.ts create mode 100644 types/ramda/test/mean-tests.ts diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index 6efc51d930..f489cbc55a 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -245,14 +245,6 @@ class F2 { const followersForUser2: (userName: string) => Promise = R.pipeWith(R.then)([db.getUserById, db.getFollowers]); }; -(() => { - const range = R.juxt([Math.min, Math.max]); - range(3, 4, 9, -3); // => [-3, 9] - - const chopped = R.juxt([R.head, R.last]); - chopped([1, 2, 3]); // => [1, 3] -}); - function square(x: number) { return x * x; } @@ -365,39 +357,11 @@ R.times(i, 5); R.reduceRight(flattenPairs, [], pairs); // => [ 'c', 3, 'b', 2, 'a', 1 ] })(); -(() => { - const values = {x: 1, y: 2, z: 3}; - - function prependKeyAndDouble(num: number, key: string, obj: any) { - return key + (num * 2); - } - - R.mapObjIndexed(prependKeyAndDouble, values); // => { x: 'x2', y: 'y4', z: 'z6' } -}); - -(() => { - const testObject: { - [key: string]: Error - } = { - hello: new Error('hello'), - }; - const errorMessages = R.mapObjIndexed( - function test(value, key) { - // value should be inferred. - return value.message + String(key); - }, testObject); - console.log(errorMessages); -}); - (() => { const b: number[][] = R.of([1]); // => [[1]] const c: number[] = R.of(1); }); -(() => { - R.length([1, 2, 3]); // => 3 -}); - (() => { function isOdd(n: number) { return n % 2 === 1; @@ -545,96 +509,13 @@ interface Obj { )(list); }); -() => { - const spacer = R.join(" "); - spacer(["a", 2, 3.4]); // => 'a 2 3.4' - R.join("|", [1, 2, 3]); // => '1|2|3' -}; - -() => { - R.last(["fi", "fo", "fum"]); // => 'fum' - R.last("abc"); // => 'c' - R.last(""); // => '' -}; - -() => { - R.lastIndexOf(3, [-1, 3, 3, 0, 1, 2, 3, 4]); // => 6 - R.lastIndexOf(10, [1, 2, 3, 4]); // => -1 -}; - -() => { - R.length([]); // => 0 - R.length([1, 2, 3]); // => 3 -}; - () => { const headLens = R.lensIndex(0); - headLens([10, 20, 30, 40]); // => 10 - headLens.set("mu", [10, 20, 30, 40]); // => ['mu', 20, 30, 40] R.view(headLens, ["a", "b", "c"]); // => 'a' R.set(headLens, "x", ["a", "b", "c"]); // => ['x', 'b', 'c'] R.over(headLens, R.toUpper, ["a", "b", "c"]); // => ['A', 'b', 'c'] }; -() => { - function double(x: number) { - return x * 2; - } - - R.map(double, [1, 2, 3]); // => [2, 4, 6] - - // functor - const numberFunctor = { - map: (fn: (c: number) => U) => { - const chars = "Ifmmp!Xpsme".split(""); - return chars.map(char => fn(char.charCodeAt(0))); - } - }; - R.map((x: number) => x - 1, numberFunctor); // => "Hello World" -}; - -() => { - interface A { - a: number; - b: number; - } - - interface B { - a: string; - b: string; - } - - R.map(R.inc, {a: 1, b: 2}); - R.map(R.toString, {a: 1, b: 2}); - - R.map(R.inc)({a: 1, b: 2}); - R.map(R.toString)({a: 1, b: 2}); -}; - -() => { - const digits = ["1", "2", "3", "4"]; - - function append(a: string, b: string): [string, string] { - return [a + b, a + b]; - } - - R.mapAccum(append, "0", digits); // => ['01234', ['01', '012', '0123', '01234']] - R.mapAccum(append)("0", digits); // => ['01234', ['01', '012', '0123', '01234']] - R.mapAccum(append, "0")(digits); // => ['01234', ['01', '012', '0123', '01234']] -}; - -() => { - const digits = ["1", "2", "3", "4"]; - - function append(a: string, b: string): [string, string] { - return [a + b, a + b]; - } - - R.mapAccumRight(append, "0", digits); // => ['04321', ['04321', '0432', '043', '04']] - R.mapAccumRight(append)("0", digits); // => ['04321', ['04321', '0432', '043', '04']] - R.mapAccumRight(append, "0")(digits); // => ['04321', ['04321', '0432', '043', '04']] -}; - () => { const sampleList = ['a', 'b', 'c', 'd', 'e', 'f']; @@ -1025,18 +906,6 @@ type Pair = KeyValuePair; * Object category */ -() => { - const objKeys = R.keys({a: 1, b: 2, c: 3}); // $ExpectType ("a" | "b" | "c")[] - const numberKeys = R.keys(1); // $ExpectType string[] - const arrayKeys = R.keys([]); // List of array members - const stringKeys = R.keys('foo'); // $ExpectType string[] -}; - -() => { - const f = new F(); - R.keysIn(f); // => ['x', 'y'] -}; - () => { interface Person { firstName: string; lastName: string; } const failedFetch = (id: string): Promise => Promise.reject('bad ID'); @@ -1091,53 +960,6 @@ type Pair = KeyValuePair; R.over(xyLens, R.negate, testObj); // => {x: [{y: -2, z: 3}, {y: 4, z: 5}]} }; -() => { - R.keys({a: 1, b: 2, c: 3}); // => ['a', 'b', 'c'] -}; - -() => { - const f = new F(); - R.keysIn(f); // => ['x', 'y'] -}; - -() => { - const headLens = R.lens( - function get(arr: number[]) { - return arr[0]; - }, - function set(val: number, arr: number[]) { - return [val].concat(arr.slice(1)); - } - ); - headLens([10, 20, 30, 40]); // => 10 - headLens.set("mu", [10, 20, 30, 40]); // => ['mu', 20, 30, 40] - - const phraseLens = R.lens( - function get(obj: any) { - return obj.phrase; - }, - function set(val: string, obj: any) { - const out = R.clone(obj); - out.phrase = val; - return out; - } - ); - const obj1 = {phrase: "Absolute filth . . . and I LOVED it!"}; - const obj2 = {phrase: "What's all this, then?"}; - phraseLens(obj1); // => 'Absolute filth . . . and I LOVED it!' - phraseLens(obj2); // => "What's all this, then?" - phraseLens.set("Ooh Betty", obj1); // => { phrase: 'Ooh Betty'} -}; - -() => { - const phraseLens = R.lensProp("phrase"); - const obj1 = {phrase: "Absolute filth . . . and I LOVED it!"}; - const obj2 = {phrase: "What's all this, then?"}; - phraseLens(obj1); // => 'Absolute filth . . . and I LOVED it!' - phraseLens(obj2); // => "What's all this, then?" - phraseLens.set("Ooh Betty", obj1); // => { phrase: 'Ooh Betty'} -}; - () => { R.merge({name: "fred", age: 10}, {age: 40}); // => { 'name': 'fred', 'age': 40 } @@ -1495,60 +1317,6 @@ type Pair = KeyValuePair; R.startsWith([1])([1, 2, 3]); // => true }; -() => { - R.lt(2, 6); // => true - R.lt(2, 0); // => false - R.lt(2, 2); // => false - R.lt(5)(10); // => true -}; - -() => { - R.lte(2, 6); // => true - R.lte(2, 0); // => false - R.lte(2, 2); // => true - R.lte(2)(10); // => true -}; - -() => { - R.mathMod(-17, 5); // => 3 - R.mathMod(17, 5); // => 2 - R.mathMod(17, -5); // => NaN - R.mathMod(17, 0); // => NaN - R.mathMod(17.2, 5); // => NaN - R.mathMod(17, 5.3); // => NaN - - const seventeenMod = R.mathMod(17); - seventeenMod(3); // => 2 -}; - -() => { - const x: number = R.max(7, 3); // => 7 - const y: string = R.max("a", "z"); // => 'z' -}; - -() => { - function cmp(obj: { x: R.Ord }) { - return obj.x; - } - - const a = {x: 1}; - const b = {x: 2}; - const c = {x: 3}; - const d = {x: "a"}; - const e = {x: "z"}; - const f = {x: new Date(0)}; - const g = {x: new Date(60 * 1000)}; - R.maxBy(cmp, a, c); // => {x: 3} - R.maxBy(cmp)(a, c); // => {x: 3} - R.maxBy(cmp)(a)(b); - R.maxBy(cmp)(f)(g); -}; - -() => { - const a: number = R.mean([2, 7, 9]); // => 6 - const b: number = R.mean([]); // => NaN -}; - () => { const a: number = R.median([7, 2, 10, 9]); // => 8 const b: number = R.median([]); // => NaN @@ -1659,14 +1427,6 @@ type Pair = KeyValuePair; * Logic category */ -() => { - // Flatten all arrays in the list but leave other values alone. - const flattenArrays = R.map(R.ifElse(Array.isArray, R.flatten, R.identity)); - - flattenArrays([[0], [[10], [8]], 1234, {}]); // => [[0], [10, 8], 1234, {}] - flattenArrays([[[10], 123], [8, [10]], "hello"]); // => [[10, 123], [8, 10], "hello"] -}; - () => { R.not(true); // => false R.not(false); // => true diff --git a/types/ramda/test/join-tests.ts b/types/ramda/test/join-tests.ts new file mode 100644 index 0000000000..702f525de1 --- /dev/null +++ b/types/ramda/test/join-tests.ts @@ -0,0 +1,7 @@ +import * as R from 'ramda'; + +() => { + const spacer = R.join(' '); + spacer(['a', 2, 3.4]); // => 'a 2 3.4' + R.join('|', [1, 2, 3]); // => '1|2|3' +}; diff --git a/types/ramda/test/juxt-tests.ts b/types/ramda/test/juxt-tests.ts new file mode 100644 index 0000000000..4959f70224 --- /dev/null +++ b/types/ramda/test/juxt-tests.ts @@ -0,0 +1,9 @@ +import * as R from 'ramda'; + +() => { + const range = R.juxt([Math.min, Math.max]); + range(3, 4, 9, -3); // => [-3, 9] + + const chopped = R.juxt([R.head, R.last]); + chopped([1, 2, 3]); // => [1, 3] +}; diff --git a/types/ramda/test/keys-tests.ts b/types/ramda/test/keys-tests.ts new file mode 100644 index 0000000000..3c2264a3cc --- /dev/null +++ b/types/ramda/test/keys-tests.ts @@ -0,0 +1,8 @@ +import * as R from 'ramda'; + +() => { + const objKeys = R.keys({a: 1, b: 2, c: 3}); // $ExpectType ("a" | "b" | "c")[] + const numberKeys = R.keys(1); // $ExpectType string[] + const arrayKeys = R.keys([]); // List of array members + const stringKeys = R.keys('foo'); // $ExpectType string[] +}; diff --git a/types/ramda/test/keysIn-tests.ts b/types/ramda/test/keysIn-tests.ts new file mode 100644 index 0000000000..78f996bd5e --- /dev/null +++ b/types/ramda/test/keysIn-tests.ts @@ -0,0 +1,12 @@ +import * as R from 'ramda'; + +class F { + [k: string]: string; + x = 'X'; + y = 'Y'; +} + +() => { + const f = new F(); + R.keysIn(f); // => ['x', 'y'] +}; diff --git a/types/ramda/test/last-tests.ts b/types/ramda/test/last-tests.ts new file mode 100644 index 0000000000..e49b770049 --- /dev/null +++ b/types/ramda/test/last-tests.ts @@ -0,0 +1,7 @@ +import * as R from 'ramda'; + +() => { + R.last(['fi', 'fo', 'fum']); // => 'fum' + R.last('abc'); // => 'c' + R.last(''); // => '' +}; diff --git a/types/ramda/test/lastIndexOf-tests.ts b/types/ramda/test/lastIndexOf-tests.ts new file mode 100644 index 0000000000..530bc72989 --- /dev/null +++ b/types/ramda/test/lastIndexOf-tests.ts @@ -0,0 +1,6 @@ +import * as R from 'ramda'; + +() => { + R.lastIndexOf(3, [-1, 3, 3, 0, 1, 2, 3, 4]); // => 6 + R.lastIndexOf(10, [1, 2, 3, 4]); // => -1 +}; diff --git a/types/ramda/test/length-tests.ts b/types/ramda/test/length-tests.ts new file mode 100644 index 0000000000..28b709dfe4 --- /dev/null +++ b/types/ramda/test/length-tests.ts @@ -0,0 +1,6 @@ +import * as R from 'ramda'; + +() => { + R.length([]); // => 0 + R.length([1, 2, 3]); // => 3 +}; diff --git a/types/ramda/test/lens-tests.ts b/types/ramda/test/lens-tests.ts new file mode 100644 index 0000000000..74988cea92 --- /dev/null +++ b/types/ramda/test/lens-tests.ts @@ -0,0 +1,30 @@ +import * as R from 'ramda'; + +() => { + const headLens = R.lens( + function get(arr: number[]) { + return arr[0]; + }, + function set(val: number, arr: number[]) { + return [val].concat(arr.slice(1)); + }, + ); + headLens([10, 20, 30, 40]); // => 10 + headLens.set('mu', [10, 20, 30, 40]); // => ['mu', 20, 30, 40] + + const phraseLens = R.lens( + function get(obj: any) { + return obj.phrase; + }, + function set(val: string, obj: any) { + const out = R.clone(obj); + out.phrase = val; + return out; + }, + ); + const obj1 = { phrase: 'Absolute filth . . . and I LOVED it!' }; + const obj2 = { phrase: "What's all this, then?" }; + phraseLens(obj1); // => 'Absolute filth . . . and I LOVED it!' + phraseLens(obj2); // => "What's all this, then?" + phraseLens.set('Ooh Betty', obj1); // => { phrase: 'Ooh Betty'} +}; diff --git a/types/ramda/test/lensIndex-tests.ts b/types/ramda/test/lensIndex-tests.ts new file mode 100644 index 0000000000..9b8a237fa8 --- /dev/null +++ b/types/ramda/test/lensIndex-tests.ts @@ -0,0 +1,7 @@ +import * as R from 'ramda'; + +() => { + const headLens = R.lensIndex(0); + headLens([10, 20, 30, 40]); // => 10 + headLens.set('mu', [10, 20, 30, 40]); // => ['mu', 20, 30, 40] +}; diff --git a/types/ramda/test/lensProp-tests.ts b/types/ramda/test/lensProp-tests.ts new file mode 100644 index 0000000000..aa93794d49 --- /dev/null +++ b/types/ramda/test/lensProp-tests.ts @@ -0,0 +1,10 @@ +import * as R from 'ramda'; + +() => { + const phraseLens = R.lensProp('phrase'); + const obj1 = { phrase: 'Absolute filth . . . and I LOVED it!' }; + const obj2 = { phrase: "What's all this, then?" }; + phraseLens(obj1); // => 'Absolute filth . . . and I LOVED it!' + phraseLens(obj2); // => "What's all this, then?" + phraseLens.set('Ooh Betty', obj1); // => { phrase: 'Ooh Betty'} +}; diff --git a/types/ramda/test/lt-tests.ts b/types/ramda/test/lt-tests.ts new file mode 100644 index 0000000000..a215e42b47 --- /dev/null +++ b/types/ramda/test/lt-tests.ts @@ -0,0 +1,8 @@ +import * as R from 'ramda'; + +() => { + R.lt(2, 6); // => true + R.lt(2, 0); // => false + R.lt(2, 2); // => false + R.lt(5)(10); // => true +}; diff --git a/types/ramda/test/lte-tests.ts b/types/ramda/test/lte-tests.ts new file mode 100644 index 0000000000..f5b7fcaae7 --- /dev/null +++ b/types/ramda/test/lte-tests.ts @@ -0,0 +1,8 @@ +import * as R from 'ramda'; + +() => { + R.lte(2, 6); // => true + R.lte(2, 0); // => false + R.lte(2, 2); // => true + R.lte(2)(10); // => true +}; diff --git a/types/ramda/test/map-tests.ts b/types/ramda/test/map-tests.ts new file mode 100644 index 0000000000..578a4a5b70 --- /dev/null +++ b/types/ramda/test/map-tests.ts @@ -0,0 +1,44 @@ +import * as R from 'ramda'; + +() => { + // Flatten all arrays in the list but leave other values alone. + const flattenArrays = R.map(R.ifElse(Array.isArray, R.flatten, R.identity)); + + flattenArrays([[0], [[10], [8]], 1234, {}]); // => [[0], [10, 8], 1234, {}] + flattenArrays([[[10], 123], [8, [10]], 'hello']); // => [[10, 123], [8, 10], "hello"] +}; + +() => { + function double(x: number) { + return x * 2; + } + + R.map(double, [1, 2, 3]); // => [2, 4, 6] + + // functor + const numberFunctor = { + map: (fn: (c: number) => U) => { + const chars = 'Ifmmp!Xpsme'.split(''); + return chars.map(char => fn(char.charCodeAt(0))); + }, + }; + R.map((x: number) => x - 1, numberFunctor); // => "Hello World" +}; + +() => { + interface A { + a: number; + b: number; + } + + interface B { + a: string; + b: string; + } + + R.map(R.inc, { a: 1, b: 2 }); + R.map(R.toString, { a: 1, b: 2 }); + + R.map(R.inc)({ a: 1, b: 2 }); + R.map(R.toString)({ a: 1, b: 2 }); +}; diff --git a/types/ramda/test/mapAccum-tests.ts b/types/ramda/test/mapAccum-tests.ts new file mode 100644 index 0000000000..d1b1c7038f --- /dev/null +++ b/types/ramda/test/mapAccum-tests.ts @@ -0,0 +1,13 @@ +import * as R from 'ramda'; + +() => { + const digits = ['1', '2', '3', '4']; + + function append(a: string, b: string): [string, string] { + return [a + b, a + b]; + } + + R.mapAccum(append, '0', digits); // => ['01234', ['01', '012', '0123', '01234']] + R.mapAccum(append)('0', digits); // => ['01234', ['01', '012', '0123', '01234']] + R.mapAccum(append, '0')(digits); // => ['01234', ['01', '012', '0123', '01234']] +}; diff --git a/types/ramda/test/mapAccumRight-tests.ts b/types/ramda/test/mapAccumRight-tests.ts new file mode 100644 index 0000000000..b66b4c6183 --- /dev/null +++ b/types/ramda/test/mapAccumRight-tests.ts @@ -0,0 +1,13 @@ +import * as R from 'ramda'; + +() => { + const digits = ['1', '2', '3', '4']; + + function append(a: string, b: string): [string, string] { + return [a + b, a + b]; + } + + R.mapAccumRight(append, '0', digits); // => ['04321', ['04321', '0432', '043', '04']] + R.mapAccumRight(append)('0', digits); // => ['04321', ['04321', '0432', '043', '04']] + R.mapAccumRight(append, '0')(digits); // => ['04321', ['04321', '0432', '043', '04']] +}; diff --git a/types/ramda/test/mapObjIndexed-tests.ts b/types/ramda/test/mapObjIndexed-tests.ts new file mode 100644 index 0000000000..77e4069ea8 --- /dev/null +++ b/types/ramda/test/mapObjIndexed-tests.ts @@ -0,0 +1,24 @@ +import * as R from 'ramda'; + +() => { + const values = { x: 1, y: 2, z: 3 }; + + function prependKeyAndDouble(num: number, key: string, obj: any) { + return key + num * 2; + } + + R.mapObjIndexed(prependKeyAndDouble, values); // => { x: 'x2', y: 'y4', z: 'z6' } +}; + +() => { + const testObject: { + [key: string]: Error; + } = { + hello: new Error('hello'), + }; + const errorMessages = R.mapObjIndexed(function test(value, key) { + // value should be inferred. + return value.message + String(key); + }, testObject); + console.log(errorMessages); +}; diff --git a/types/ramda/test/mathMod-tests.ts b/types/ramda/test/mathMod-tests.ts new file mode 100644 index 0000000000..fdf64a0f55 --- /dev/null +++ b/types/ramda/test/mathMod-tests.ts @@ -0,0 +1,13 @@ +import * as R from 'ramda'; + +() => { + R.mathMod(-17, 5); // => 3 + R.mathMod(17, 5); // => 2 + R.mathMod(17, -5); // => NaN + R.mathMod(17, 0); // => NaN + R.mathMod(17.2, 5); // => NaN + R.mathMod(17, 5.3); // => NaN + + const seventeenMod = R.mathMod(17); + seventeenMod(3); // => 2 +}; diff --git a/types/ramda/test/max-tests.ts b/types/ramda/test/max-tests.ts new file mode 100644 index 0000000000..2d576ee851 --- /dev/null +++ b/types/ramda/test/max-tests.ts @@ -0,0 +1,6 @@ +import * as R from 'ramda'; + +() => { + const x: number = R.max(7, 3); // => 7 + const y: string = R.max('a', 'z'); // => 'z' +}; diff --git a/types/ramda/test/maxBy-tests.ts b/types/ramda/test/maxBy-tests.ts new file mode 100644 index 0000000000..75b4a70118 --- /dev/null +++ b/types/ramda/test/maxBy-tests.ts @@ -0,0 +1,19 @@ +import * as R from 'ramda'; + +() => { + function cmp(obj: { x: R.Ord }) { + return obj.x; + } + + const a = { x: 1 }; + const b = { x: 2 }; + const c = { x: 3 }; + const d = { x: 'a' }; + const e = { x: 'z' }; + const f = { x: new Date(0) }; + const g = { x: new Date(60 * 1000) }; + R.maxBy(cmp, a, c); // => {x: 3} + R.maxBy(cmp)(a, c); // => {x: 3} + R.maxBy(cmp)(a)(b); + R.maxBy(cmp)(f)(g); +}; diff --git a/types/ramda/test/mean-tests.ts b/types/ramda/test/mean-tests.ts new file mode 100644 index 0000000000..a5855ddb65 --- /dev/null +++ b/types/ramda/test/mean-tests.ts @@ -0,0 +1,6 @@ +import * as R from 'ramda'; + +() => { + const a: number = R.mean([2, 7, 9]); // => 6 + const b: number = R.mean([]); // => NaN +}; diff --git a/types/ramda/tsconfig.json b/types/ramda/tsconfig.json index 315f86aa66..ec1711a397 100644 --- a/types/ramda/tsconfig.json +++ b/types/ramda/tsconfig.json @@ -112,6 +112,26 @@ "test/is-tests.ts", "test/isArrayLike-tests.ts", "test/isEmpty-tests.ts", - "test/isNaN-tests.ts" + "test/isNaN-tests.ts", + "test/join-tests.ts", + "test/juxt-tests.ts", + "test/keys-tests.ts", + "test/keysIn-tests.ts", + "test/last-tests.ts", + "test/lastIndexOf-tests.ts", + "test/length-tests.ts", + "test/lens-tests.ts", + "test/lensIndex-tests.ts", + "test/lensProp-tests.ts", + "test/lt-tests.ts", + "test/lte-tests.ts", + "test/map-tests.ts", + "test/mapAccum-tests.ts", + "test/mapAccumRight-tests.ts", + "test/mapObjIndexed-tests.ts", + "test/mathMod-tests.ts", + "test/max-tests.ts", + "test/maxBy-tests.ts", + "test/mean-tests.ts" ] } \ No newline at end of file