Everything seems to be running smoothly:
type fun = (uid: string) => string
const abc: fun = value => value
const efg = (callback:fun, value:string) =>callback(value)
console.log(efg(abc, "123"))
However, when we try to make it generic, we encounter an error:
type fun = (uid: string) => string
const abc: fun = value => value
const efg = <T>(callback:T, value:string) =>callback(value)
console.log(efg(abc, "123"))
Error:
This expression is not callable. Type 'unknown' has no call signatures.(2349)
I checked out https://www.typescriptlang.org/docs/handbook/generics.html but found nothing about Generic Function Type Literals.
I need the ability to pass different functions as arguments, which is why I am exploring this approach.
Is there a workaround or hack for this issue, or is there a proper solution available?