Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

310
Views
Call `super` on JavaScript instance method

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?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Parcel v2 supports transpiling es6 class syntax by default using swc. One "gotcha" is that if it detects a .babelrc/babel.config.json file in your project, it will switch to transpiling using babel, and then it is up to you to make sure that the config you provided will transpile classes.

According to the docs:

if you're only using @babel/preset-env, @babel/preset-typescript, and @babel/preset-react, Babel may no longer be necessary. Parcel supports all of these features automatically without a Babel config, and Parcel's default transpiler is much faster than Babel.

So the first thing I would try is just deleting any .babelrc/babel.config.json files in your project so you can try it out with swc. If that doesn't work (maybe because you're doing something else that swc doesn't support), make sure that @babel/preset-env is included in your babel config.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!