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

Minification not generating the file correctly when BigInt is involved #31

Open
sapnc opened this issue Mar 21, 2024 · 2 comments
Open
Labels
help wanted Extra attention is needed

Comments

@sapnc
Copy link

sapnc commented Mar 21, 2024

Installed product versions

  • Visual Studio: 2022.
  • This extension: 2.9.9

Description

The Minifier not generating the script when BigInt() method is used with a higher values.

Steps to recreate

Adding a sample code. The intention of this code is to check if the given string is well within the C# Int64 range.
let TryParseLong = function (str, defaultValue) {
var retValue = defaultValue;
if (str !== null) {
if (str.length > 0 && str.length <= 19) {
if (!isNaN(str)) {
if (BigInt(str) < BigInt("9223372036854775807")) { //Int64.MaxValue is "9223372036854775807"
retValue = BigInt(str);
}
console.log(retValue);
}
}
}

return retValue;

}

Current behavior

The minifier generates the minification file
However the BigInt("9223372036854775807") gets generated as -9223372036854775808n

The minified code generated on the machine is
let TryParseLong=function(n,t){var i=t;return n!==null&&n.length>0&&n.length<=19&&(isNaN(n)||(BigInt(n)<-9223372036854775808n&&(i=BigInt(n)),console.log(i))),i},a=123456,b=TryParseLong(a,-1);alert(b);

Expected behavior

Ideally it should stay as
9223372036854775808n

let TryParseLong=function(n,t){var i=t;return n!==null&&n.length>0&&n.length<=19&&(isNaN(n)||(BigInt(n)<9223372036854775808n&&(i=BigInt(n)),console.log(i))),i},a=123456,b=TryParseLong(a,-1);alert(b);

@sapnc sapnc changed the title Minification not generating when BigInt is involved Minification not generating the file correctly when BigInt is involved Mar 21, 2024
@failwyn failwyn added the help wanted Extra attention is needed label Apr 3, 2024
@failwyn
Copy link
Owner

failwyn commented Apr 3, 2024

Is this supported by NUglify?

@failwyn
Copy link
Owner

failwyn commented Aug 1, 2024

This is caused by targeting .Net 3.5 in NUglify; if you use BigInt("9007199254740991") for your comparison, it works correctly; if you aren't expecting numbers to be larger than that.

trullock/NUglify#158

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants