Reputation: 37381
I can't seem to find any clear instruction on how to cast an argument to an anonymous function. I can cast on variable assignment, just not sure if this is possible and how.
Since I'm using lodash the typings define the argument as any
but I need to cast it to a custom object, since in reality it would be.
_.findLast(this.children, function((CustomObject) node) {
node.customMethod();
})
Upvotes: 0
Views: 448
Reputation: 37381
Blind luck led me to discover that (<CustomObject> node).customMethod();
works.
Upvotes: 1
Reputation: 35358
This should work
_.findLast(this.children, function(node: any) {
var co = <CustomObject> node;
co.customMethod();
})
Upvotes: 2