I'm working on an ionic 2 project using typescript 2.0.6.
I have a Base class which manage some behaviors and I inherit several classes from this base class. And I want to be able to get the name of the actual class (not the base one).
Here is my code :
export class AbstractModel {
oneInstanceMethod() {
this.getClassName();
}
static oneStaticMethod() {
this.getClassName();
}
getClassName() {
return (<any>this).constructor.name;
}
static getClassName() {
return (<any>this).name;
}
}
export class MyClass1 extends AbstractModel {
}
export class MyClass2 extends AbstractModel {
}
And I have 2 kind of calls : Either MyClass1.oneStaticMethod() or (new MyClass2).oneInstanceMethod().
My problem is that this code was working before (now I get 'e' because it returns the function e()) I made some upgrade in my ionic project. I think my typescript version has been upgraded (i'm not sure but I think it was the 1.8 before).
How can I solve this ? I tried many things (like creating variables to store the values, but neither works in static mode AND instance mode).
Thanks !