获取typescript中的函数名称 [英] Get name of function in typescript

查看:674
本文介绍了获取typescript中的函数名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来获取函数传递参数

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);

你可以在jsbin
http://jsbin.com/loluhu/edit?js,console

you can check this in jsbin http://jsbin.com/loluhu/edit?js,console

推荐答案

我发现这是打字稿中的一个错误

I found this is a bug in typescript

你可以在这里找到解决方案
不提供功能名称的WordScript

you can find solution here TypeScript not providing function name

这篇关于获取typescript中的函数名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆