Given
class BaseClass{
count:number=0;
public someMethod=():void =>{
this.count++;
}
}
class ChildClass extends BaseClass{
public someMe
Without a function implementation in the prototype, there's no way for the derived class to 'find' the base class implementation. You can separate it out so that you have one method for preserving this
and another for using via super
:
class BaseClass {
count: number = 0;
someMethodImpl() {
this.count++;
}
public someMethod = this.someMethodImpl;
}
class ChildClass extends BaseClass {
public someMethod = (): void=> {
super.someMethodImpl();
//Do more work here.
}
}