typescript手册目前没有关于箭头功能的内容.正规函数
function identity<T>(arg: T): T {
return arg;
}
箭头函数的语法是什么?
typescript手册目前没有关于箭头功能的内容.正规函数
function identity<T>(arg: T): T {
return arg;
}
箭头函数的语法是什么?
语言规范在第64f页上有说明
A construct of the form < T > ( ... ) => { ... } could be parsed as an arrow function expression with a type parameter or a type assertion applied to an arrow function with no type parameter. It is resolved as the former[..]
例子:
// helper function needed because Backbone-couchdb's sync does not return a jqxhr
let fetched = <
R extends Backbone.Collection<any> >(c:R) => {
return new Promise(function (fulfill, reject) {
c.fetch({reset: true, success: fulfill, error: reject})
});
};