Hi I'm trying to pass in a function as an argument to another function and in doing so need to provide the type signature for that function. I thought this would do the trick:
const funct1 = (obj1: Object, funct2: <T, K>(a:T) => K, obj2: any) => {
///...
}
However when I call it with something like this:
const convertFromDate = (obj: Date) : number => {
return obj.valueOf() / 1000;
};
funct1(d1, convertFromDate, Date) // error: Type 'number' is not assignable to type 'K'.
//'number' is assignable to the constraint of type 'K',
// but 'K' could be instantiated with a different subtype of constraint 'unknown'.
I got the above error. How should I define the type signature of a function that takes an argument of one type and returns another?