class AbstractClass {
constructor() {
}
set property(value) {
this.property_ = value;
}
get property() {
return this.property_;
}
}
class Subclass extends AbstractClass {
constructor() {
super();
}
set property(value) {
super.property = value;
if (!(this.property_ instanceof SubclassAssociatedClass)) throw new TypeError();
}
}
Override the setattribute method and it seems that the method getshould also be redefined, otherwise it returns undefined(i.e. the method is getnot inherited, uncomment the subclass method get property()above, and everything works fine).
I assume this is part of the specification. It will follow, although it is possible if the behavior was the result of cross-compilation. Just to be sure, is this the right way to code overridden setters and getters (both at the same time or not at all)?
source
share