How to get Generic class name of typescript?

You must understand that Typescript is just a transpiler (compiler to javascript). Some of the syntax sugar (such as generics) are working only in type-checking phase (and also it’s helpful for intellisense in your IDE/text-editor).

However assignment to a variable is happening in runtime, in runtime it’s just a plain Javascript. There are no types and no generics in runtime.

But here’s the easiest way I would do it:

class Some<T> {
    private TName : string;
    constructor(x : T&Function) {
        this.TName = x.name;
    }
}

class Another {

}

const some = new Some<Another>(Another);

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)