javascripttypescripttemplatesreflection

How can I get the string of a type in JavaScript/TypeScript?


In C# you could do something like this :

string typeName = typeof(int).FullName;

And the value of typeName would be System.Int32. (Refer this question for reference).

So, my question is, how can I achieve the same thing in JavaScript or TypeScript?

Please note that I do not want to get the type name from an object, I only want to get it from a type just like the example code above.


Solution

  • I just found out that the type-name package in Node.js can solve this problem.