Is it possible to get the name of a generic type param in typescript.
having this method.
getName<T>(): string {
.... use some operator or something
}
using it like this
class MyClass{
}
getName<MyClass>(); ///=> should return 'MyClass'
I've tried using https://www.npmjs.com/package/ts-nameof but it does not work.
Doing
const name = nameof<T>();
fails
Or maybe is there another way of achieving this ?