How to type compose
function ?
#3346
Replies: 1 comment
-
The error you are getting is not from Ramda or how While typescript does throw an error for import { compose } from 'ramda';
const foo = (a: number) => a;
const myCompose = (fns: Array<(a: number) => number>) => {
// @ts-expect-error
return compose(...[...fns, foo]);
};
const fn = myCompose([(a) => a * 2]);
fn(2); // 4 The I hope that helps Note: Updated 3/9/23 |
Beta Was this translation helpful? Give feedback.
-
I want to use
compose
function with a wrapper function when I want to pass some functions that should be composed with another function.Example:
But I get TS error:
A spread argument must either have a tuple type or be passed to a rest parameter.ts(2556)
Demo: Codesandbox
Is there some solution for this?
Beta Was this translation helpful? Give feedback.
All reactions