When I try to override a parent method and I use super inside, I get this error:
error TS2340: Only public and protected methods of the base class are accessible via the 'super' keyword.
return super.toJson(["password", ...blacklist]);
This is an example:
abstract class BaseUser {
name: string;
constructor(name: string) {
this.name = name;
}
toJson = () => {
return Object.assign({}, this);
}
}
class MyUser {
...
toJson = (blacklist) => {
...
const obj = super.toJson();
...
}
}
Don't know what I'm doing wrong...
extendBaseUser in you code. Even if it did,toJsonis not a method it is a field that is a function and thus not present on the prototype (it is assigned in the constructor) and you can't call it throughsuper. Make it a regular method and it should work