In a library that I wish to extend without modifying its code, several classes inherit from the same imported one. That is in this BaseClass
I would need to overwrite a specific method.
- In the library (written in TypeScript) :
import { BaseClass } from './base_class';
export class ClassA extends BaseClass {}
import { BaseClass } from './base_class';
export class ClassB extends BaseClass {}
…
- In the external extension I wish to write :
import { BaseClass } from 'library';
export class ExtendedBaseClass extends BaseClass {
oneMethod() {
const data = BaseClass.prototype.oneMethod.call(this);
// make additional things with data
return data;
}
}
Is there a way for this new ExtendedBaseClass
to become the parent of all ClassX
s ? At least in a new extended and re-exported version of them without the need to copy their internal code.