Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: must call super constructor before using 'this' in derived class constructor #2138

Open
skjbulcher opened this issue Nov 8, 2022 · 4 comments

Comments

@skjbulcher
Copy link

I've installed shepherd.js as a node module using npm (version 10.0.1), and I'm getting this message when attempting to create a tour:

Uncaught ReferenceError: must call super constructor before using 'this' in derived class constructor


My code is the following:

import Shepherd from 'shepherd.js';

        this.tour = new Shepherd.Tour({
            useModalOverlay: false,
            defaultStepOptions: {
                classes: 'shadow-md bg-purple-dark',
                scrollTo: {behavior: 'smooth', block: 'center'},
            },
        });

The debugger points to this line of code:

class Tour extends Evented {
          /** ... **/
	  constructor(options) {
	    var this$1 = this;   // <----  This is where the exception is raised

	    if (options === void 0) {
	      options = {};
	    }

	    super(options);    // <--- complains this should have already been called?

When I download and included the file from the releases page manually in my app, it doesn't raise the exception. I'm a little confused as to why it works that way but not when I use the version from npm?

@RobbieTheWagner
Copy link
Member

@skjbulcher can you try version 11? I'm not sure if it will make a difference or not. Are you using a framework?

@skjbulcher
Copy link
Author

I'm not at a point where I can make changes, sorry

@RobbieTheWagner
Copy link
Member

Without any info about if you are using a framework or not, or how you have things setup, I cannot help.

@skjbulcher
Copy link
Author

Well, the error refers to the line I have pointed out in the code above. super is called after referencing this, which is not allowed in a derived class constructor. All of the information that led to the error is contained in the code snippet above.

I don't know why it worked when I downloaded the file from the releases page manually (is it different than the npm version?), but the error is based on hard JavaScript rules governing inheritance.

Sorry that I don't have time to go back and forth on this issue. I have a whole lot piled on me right now, and I've moved on from this project since I filed the report. I'm surprised no one else has commented on this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants