Minification not generating the file correctly when BigInt is involved
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);
Is this supported by NUglify?
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.
https://github.com/trullock/NUglify/issues/158