I want to declare this function type:
function currying1 (fn: any, params: any) {
if(fn.length <= params.length){
return fn(...params)
}
return (...p: any) => currying1(fn, [...params, ...p])
}
Then I try to declare:
type Parameters2<T> = T extends (...args: infer P) => any ? Partial<P> : never
declare function Currying2<Fn extends (...args: any[]) => any, P extends Parameters2<Fn> = []>(fn: Fn, params: Parameters2<Fn>): any
I want to set P default value to [], but i get this type error
Type '[]' does not satisfy the constraint 'Parameters2'. (2344)
Playground with code (Error is on line 64)