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

dist/tinysort.charorder.min.js has a variable use before initialization #174

Open
krugar opened this issue Apr 26, 2021 · 1 comment
Open

Comments

@krugar
Copy link

krugar commented Apr 26, 2021

The current version of tinysort.charorder.min.js causes the following TypeError (in Firefox 88.0):

Uncaught TypeError: j is undefined (tinysort.charorder.min.js:1:206)

The way I understand this is that Webpack moves the const declaration/initialization of allCharList into a var declaration/initialization below the function definition of prepare, in the assumption that the declaration is hoisted and everything should work. But JavaScript only hoists the declaration of the variable, not the initialization, which means that when allCharList.slice(0) is called, the variable exists, but is not yet initialized, resulting in the "is undefined" error above.

I don't quite know how to tell Webpack to not make this mistake (or whether newer versions of Webpack don't do this), but I'd assume separating declaration and initialization into distinct statements would work.

@Sjeiti
Copy link
Owner

Sjeiti commented Apr 26, 2021

Thanks for the find. I'll try to have a look at it this week.
One would think with const and let the days of having to deal with hoisting would be behind us.

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