Block-scoped variable 'wizard' used before its declaration.ts(2448)

Viewed 3485

Here is the code:

let args = {
      "wz_nav_style": "dots", // dots, tabs, progress
      "buttons": true,
      "navigation": 'all' // buttons, nav, all
    };

const wizard = new wizard(args);

wizard.init();

document.addEventListener("submitWizard", function (e) {
  alert("Form Submit");
});

I get the error:

Block-scoped variable 'wizard' used before its declaration.ts(2448)

How to solve this?

1 Answers

The constant name wizard overshadows the reference of the constructor named as the same. Changing the constant name to something other than the constructor would solve the problem.

const wiz = new wizard(args);

wiz.init();
Related