From d3cf467af3c37cd3e1d948dc89260fd7dfd73354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9E=97=E9=9B=86=E5=9B=A2?= Date: Thu, 27 Jun 2019 01:30:37 +0800 Subject: [PATCH] ramda: add support of applying `chain` to function type argument (#36078) * ramda: add support of applying `chain` to function type argument * lint * add test for `chain` --- types/ramda/index.d.ts | 2 ++ types/ramda/ramda-tests.ts | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 0994fe3651..9c55fae594 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -28,6 +28,7 @@ // Krantisinh Deshmukh // Pierre-Antoine Mills // Brekk Bockrath +// Jituan Lin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 3.3 @@ -964,6 +965,7 @@ declare namespace R { */ chain(fn: (n: T) => ReadonlyArray, list: ReadonlyArray): U[]; chain(fn: (n: T) => ReadonlyArray): (list: ReadonlyArray) => U[]; + chain(fn: (x0: X0, x1: X1) => R, fn1: (x1: X1) => X0): (x1: X1) => R; /** * Restricts a number to be within a range. diff --git a/types/ramda/ramda-tests.ts b/types/ramda/ramda-tests.ts index cb16a1c2a9..5b63b3123f 100644 --- a/types/ramda/ramda-tests.ts +++ b/types/ramda/ramda-tests.ts @@ -723,6 +723,11 @@ R.times(i, 5); R.chain(duplicate, [1, 2, 3]); // => [1, 1, 2, 2, 3, 3] R.chain(duplicate)([1, 2, 3]); // => [1, 1, 2, 2, 3, 3] + const result1: number[] = R.chain(R.append, R.head)([ + 1, + 2, + 3 + ]); // => [1, 2, 3, 1] }; () => {