diff --git a/types/ramda/index.d.ts b/types/ramda/index.d.ts index 153d78fe22..2f3beec69e 100644 --- a/types/ramda/index.d.ts +++ b/types/ramda/index.d.ts @@ -242,8 +242,8 @@ export function call(fn: (...args: readonly any[]) => (...args: readonly any[]) * `chain` maps a function over a list and concatenates the results. * This implementation is compatible with the Fantasy-land Chain spec */ -export function chain(fn: (n: T) => U[], list: readonly T[]): U[]; -export function chain(fn: (n: T) => U[]): (list: readonly T[]) => U[]; +export function chain(fn: (n: T) => readonly U[], list: readonly T[]): U[]; +export function chain(fn: (n: T) => readonly U[]): (list: readonly T[]) => U[]; export function chain(fn: (x0: X0, x1: X1) => R, fn1: (x1: X1) => X0): (x1: X1) => R; /** diff --git a/types/ramda/test/chain-tests.ts b/types/ramda/test/chain-tests.ts index 4f7635fd13..d97b8e494a 100644 --- a/types/ramda/test/chain-tests.ts +++ b/types/ramda/test/chain-tests.ts @@ -5,10 +5,24 @@ import * as R from 'ramda'; return [n, n]; } + function duplicateConst(n: number) { + return [n, n] as const; + } + + function duplicateReadonly(n: number): ReadonlyArray { + return [n, n]; + } + 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] + + R.chain(duplicateConst, [1, 2, 3] as const); // => [1, 1, 2, 2, 3, 3] + R.chain(duplicateConst)([1, 2, 3] as const); // => [1, 1, 2, 2, 3, 3] + + R.chain(duplicateReadonly, [1, 2, 3]); // => [1, 1, 2, 2, 3, 3] + R.chain(duplicateReadonly)([1, 2, 3]); // => [1, 1, 2, 2, 3, 3] };