This is working, no problem:
type fun = (uid: string) => string
const abc: fun = value => value
const efg = (callback:fun, value:string) =>callback(value)
console.log(efg(abc, "123"))
But if we go for generic, it will 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 read https://www.typescriptlang.org/docs/handbook/generics.html but it say nothing about Generic Function Type Literals.
I need to pass different functions as an argument, which is why I need this.
Is there any work around/hack or there is actually a proper way to do this?