After creating a function called compose
, it looks like this:
const composeTyped = <T, U, R>(f: (x: T) => U, g: (y: U) => R) => (x: T) => g(f(x));
It appears to me that both functions f
and g
fall under the type fGeneric
, which is defined as follows:
type fGeneric = <T, R>(arg: T) => R;
The issue I'm facing is understanding whether and how I can utilize the fGeneric
type to specify the types of f
and g
in composedType
. Specifically, if I attempt the following:
const composeTyped_ = <T, U, R>(f: fGeneric, g: fGeneric) => (x: T) => g(f(x));
The composeTyped_
function ends up with the type (x: T) => unknown
. However, my goal is to have it be of type (x: T) => R
.