From fda3aeee066db68c0fedf8e4b8a30fc4b5466293 Mon Sep 17 00:00:00 2001 From: sgoll <1277035+sgoll@users.noreply.github.com> Date: Mon, 26 Feb 2018 17:15:46 +0100 Subject: [PATCH] [ramda] Add type for string-based reverse (#23927) * Add type for string-based reverse * Add test for string-based reverse * Use separate documentation for each overload --- types/ramda/index.d.ts | 4 ++++ types/ramda/ramda-tests.ts | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 108a12bf0e..205df9f569 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -1601,6 +1601,10 @@ declare namespace R { * Returns a new list with the same elements as the original list, just in the reverse order. */ reverse(list: ReadonlyArray): T[]; + /** + * Returns a new string with the characters in reverse order. + */ + reverse(str: string): string; /** * Scan is similar to reduce, but returns a list of successively reduced values from the left. diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index eacb4558e3..8aef1c65fc 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -977,6 +977,13 @@ type Pair = KeyValuePair; R.reverse([]); // => [] }; +() => { + R.reverse('abc'); // => 'cba' + R.reverse('ab'); // => 'ba' + R.reverse('a'); // => 'a' + R.reverse(''); // => '' +}; + () => { const numbers = [1, 2, 3, 4]; R.scan(R.multiply, 1, numbers); // => [1, 1, 2, 6, 24]