I've tried this code with TypeScript 2.6 and 3.4:
abstract class Base {
private _prop = false;
public get prop() { return this._prop; }
public setProp(v) { this._prop = v; }
private _otherProp = false;
public get otherProp() { return this._otherProp; }
public set otherProp(v) { this.setOtherProp(v); }
public setOtherProp(v) { this._otherProp = v; }
}
class MyBase extends Base {
public set prop(v) { this.setProp(v); }
}
const base = new MyBase();
base.setProp(true);
base.setOtherProp(true);
console.log(`prop = ${base.prop}`); // prop = undefined
console.log(`otherProp = ${base.otherProp}`); // otherProp = true
Why the different result? Note that if I comment out the set prop() in the MyBase class then both properties return true, however this setter is never even executed, so why does it matter that it's there?
Run the code yourself (results in the console)