I am using below code using ramda in typescript and it keeps showing error that type is not matching:
R.pipe(R.drop(2), R.dropLast(5))("hello world");
TS2769: No overload matches this call. The last overload gave the following error. Argument of type '{ (xs: string): string; (xs: readonly unknown[]): unknown[]; }' is not assignable to parameter of type '(x0: readonly unknown[], x1: unknown, x2: unknown) => string'. Types of parameters 'xs' and 'x0' are incompatible. Type 'readonly unknown[]' is not assignable to type 'string'.
How should fix this?
It seems the type inference needs a bit of extra help to let it know that you want the type narrowed to a string
.
e.g.
R.pipe<string, string, string>(R.drop(2), R.dropLast(5))("hello world")
// or
R.pipe(R.drop(2) as (str: string) => string, R.dropLast(5))("hello world")