Open trullock opened 3 years ago
I think this example is basically the same thing, but I just wanted to note it because it caused me a slight headache figuring out why my code wasn't working. Default parameters combined with the object destructuring can lead to issues/bugs.
function test1({ locale = "en-US" } = {}) {
console.log(locale);
}
test1({ locale: "ja-JP" });
I would expect "ja-JP" to be logged, but "en-US" is logged because test1 is turned into test1({n="en-US"}={}){console.log(n)}
And then of course something like test1({n:55})
could confusingly cause 55 to be logged.
This issue is just a compression enchancement, your example is a bug, can you open a new issue for it please
this:
let y = ({ a, b, ...rest }) => a + b + rest.length;
becomes:
let y=({a:n,b:t,...i})=>n+t+i.length
It didn't need to rename
a
andb
, this made it worse