Is there a method in TypeScript to retrieve the name of a generic type parameter?
Consider the following method:
getName<T>(): string {
.... implement using some operator or technique
}
You can use it like this:
class MyClass{
}
getName<MyClass>(); ///=> should return 'MyClass'
I attempted to utilize https://www.npmjs.com/package/ts-nameof, but it was unsuccessful.
Trying to do this:
const name = nameof<T>();
results in an error.
Are there any alternative methods for achieving this outcome?