class Base {
static getCorrectFoo(): any {
return this;
}
static get foo(): any {
return this;
}
}
class Inherited extends Base {}
Base.foo === Base;
Base.getCorrectFoo() === Base;
Inherited.foo === Base; /// Should be `Inherited`
Inherited.getCorrectFoo() === Inherited;
I believe this is because the foo getter will be defined via Object.defineProperty(Base, {..}), which hard-wires this to Base within the getter, rather than binding as expected to Inherited in Inherited.foo.