I was looking for a way to get name of function passing in parameter
console.clear();
class A{
test(){
}
testCall(fnc:Function){
console.log(fnc.name); // i want it display test here not empty
console.log(fnc);
}
}
var a=new A();
a.testCall(a.test);
you can check this in jsbin http://jsbin.com/loluhu/edit?js,console
I found this is a bug in typescript
you can find solution here TypeScript not providing function name
You can extend the Function interface as follows:
interface Function {
name: string;
}
function foo() {}
alert(foo.name);
See here for a fuller explanation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With