If I have a base class that has a getter and setter, and I override the getter in a subclass (but not the setter), I am getting Cannot set property x of #<MyClass> which has only a getter … Do I really have to have such a superfluous method in my subclass like:
set x(val: any) {
super.x = val;
}
??
>Solution :
This is something really weird, as per ES6 i experienced that lets say design issue, both get and set must be defined on child class. As a work around i ended up defining methods instead of accessors.
class A
{
protected _val:number;
getval():number
{
return this._val;
}
}
class B extends A
{
setval(value:number)
{
this._val = value;
}
}
Theres a large thread here