Class properties being reset to undefined
Why is this happening? I have stepped through the debugger and no matter what, if I set a property in super() it gets reset to undefined
undefined after the call unless it's being explicitly set to undefined later in the class constructor or in some method that gets called before you check the value.super()super()super()propDerivedclass Base {
constructor(public prop: any) {}
}
class Derived extends Base {
constructor() {
super("initial value");
console.log(this.prop); // Should log "initial value"
}
}
const instance = new Derived();