Within this code snippet, the function requires two arguments: one for the function that needs to be wrapped and another for the argument producer.
function wrapper<K extends Array<any>, T>(fn: (...args: K) => T, pd: (...args: any) => K): T {
return fn(...pd());
}
wrapper((id: number) => id, (id: number) => {
return [id];
})
However, there seems to be an error in the declaration of the producer function:
Argument of type '(id: number) => number[]' is not assignable to parameter of type '(...args: any) => [id: number]'.
Type 'number[]' is not assignable to type '[id: number]'.
Target requires 1 element(s) but source may have fewer.(2345)
Is there a way to resolve this issue without altering the structure of the function? Thank you!