There is no way in typescript to do this. Type type parameters can only be displayed where types can be displayed in declarations; they are not available at run time. The reason for this is simple: for each method of a universal class, a single javascript function is created, and there is no way for this function to find out what actual type was passed as a parameter of the type type.
If you need this information at runtime, you need to add a parameter to the constructor and pass it yourself when called:
class Controller<T extends Model>{ constructor(cls: typeof Model){ if (cls.hasStatus) { } } } let c = new Controller<MyModel>(MyModel);
Here's what it looks like when compiling in javascript to illustrate this point: there is nothing left of the general parameters, and if you remove the cls parameter, there is no information about where hasStatus should appear.
var Controller = (function () { function Controller(cls) { if (cls.hasStatus) { } } return Controller; }()); var c = new Controller(MyModel);
artem source share