-
Notifications
You must be signed in to change notification settings - Fork 14
Duplicate variable name used in minified code #38
Description
Installed product versions
- Visual Studio: 2022
- This extension: [example 1.1.21]
Description
Variable t is used by the minifier as the incoming parameter, but its also used to declare a const in the same function.
Steps to recreate
This is part of a large project so might not reproduce successfully.
Source javascript:
this.getselectedtext = function (index) {
if (selectmode === "multiple") {
const allselected = $tree.find(".z");
const thisone = allselected[index];
return thisone.text();
}
else {
const thisselected = $tree.find(".stn");
return thisselected.text();
}
};Compiled javascript with line feeds put in
this.getselectedtext=function(t)
{
if(u==="multiple")
{
const i=n.find(".z"),r=i[t];
return r.text()}
const t=n.find(".stn");
return t.text()
};In the above, you can see we have function(t) and later we have const t, causing a compilation error.
After reinstalling, and giving the variable a slightly different name, this made it compile with an "else" statement, but the problem still exists
this.getselectedtext=function(t){if(u==="multiple"){const i=n.find(".z"),r=i[t];return r.text()}else{const t=n.find(".stn");return t.text()}};Current behavior
It is declaring a const t using the same variable name t as in function(t)
Expected behavior
Choose a different name for internal variables to function names
I have been using this tool for production builds on the same code for several months and not seen any problems, so now surprised that it is doing this. I did not update the extension but it seems to be the latest.