Why am I encountering the error message "Abstract property 'field0' in class 'SuperAbstractClass' cannot be accessed in the constructor", even though upon inspecting the transpiled code, it appears that we do have access to this field? Alternatively, we could run it in the TypeScript playground to observe that field1 is set to "default value"
abstract class SuperAbstractClass {
public abstract field0: string = 'default value';
public abstract field1: string;
}
abstract class SubAbstractClass extends SuperAbstractClass {
public field1: string = this.field0;
}
class SuboncreteClass extends SubAbstractClass {
public field0: string = '';
}
var a = new SuboncreteClass()
console.log(a);
Transpiled
"use strict";
class SuperAbstractClass {
constructor() {
this.field0 = 'default value';
}
}
class SubAbstractClass extends SuperAbstractClass {
constructor() {
super(...arguments);
this.field1 = this.field0;
}
}
class SuboncreteClass extends SubAbstractClass {
constructor() {
super(...arguments);
this.field0 = '';
}
}
var a = new SuboncreteClass();
console.log(a);