如何将参数传递给保存函数的变量 -
export const filter = Curry(_filter) as ICurryFunction<T>
我收到错误 - Cannot find name T
filter
常量存储函数。
Curry.ts
function Curry<T, R> (f: ICurryFunction<T>): ICurryFunction<T> {
return function curried (...t: any[]): T | ICurryFunction<T> {
if (t.length === 0) return curried
if (t.length >= f.length) return f(...t)
return curried.bind(this, ...t)
}
}
ICurryFunction.ts
interface ICurryFunction<T> {
(...k: any[]): T | ICurryFunction<T>
}
完整代码 https://github.com/tusharmath/observable-air/blob/master/src/main.ts#L24