如何在打字稿中编写类似函数的类型签名?
var apply = (fn) => (list) =>
fn.apply(null, list);
答案 0 :(得分:2)
你走了:
var apply : (fn:Function) => (list:any[]) => any = (fn) => (list) =>
fn.apply(null, list);
另一个样本:
var foo = (a:number) => (b:number) => (c:number) => {
return a + b + c;
};
var add1 = foo(1);
var add2 = foo(1)(1);
console.log(add1(1)(1)); // 3
console.log(add2(1)); // 3