I'm attempting to call super on an instance method of an ES6 style class, and I'm getting parcel/babel build errors.
@parcel/transformer-babel: 'super' is only allowed in object methods and classes. (1291:21)
My code effectively looks like this
class BaseClass {
constructor(params) {
this.params = params;
}
matches(other) {
// do some matching logic
return true; // or false
}
}
class MyClass extends BaseClass {
matches(other) {
let match = super.matches(other);
// do some additional matching logic
return true; // or false
}
}
The error is when I call super.matches(other) in MyClass.
All the documentation I can find on super talks about its use in constructor, which is fine, and its use in static methods, but I have found no mention of instance methods.
Does this just not work in JS, am I doing it wrong, or is it something to do with the babel transformer or parcel?