How can I specify the parameter type for the callback function handle?
const util = (handle: (p) => string) => ({
// I expect the log function's parameter [p] type to come from the handle function's parameter type
log: (p: Parameters<typeof handle>[0]) => console.log(handle(p))
});
// Currently, the log function parameter is recognized as type 'any' instead of 'string'
const { log } = util((a: string) => String(a));
// Expect log function parameter to be string
const { log } = util((a: string) => String(a));
// Expect log function parameter to be int
const { log } = util((a: int) => String(a));
// Expect log function parameter to be object
const { log } = util((a: object) => String(a));
I am aware that the type can be specified in a generic way, but I am curious if the type declared in the parameter signature of the callback function can be passed along.