-
-
Notifications
You must be signed in to change notification settings - Fork 225
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
Mangler using wrong variable name in some cases #369
Comments
Related #326 |
Similar issue with broken array destructuring:
is converted to:
|
I also have a similar issue, but this is with destructuring in function arguments. Was unsure if I should file a new issue or put it in this one. Given (repl):const Main = ({ thing: Thing = 'div' }) => <Thing />;
<Main thing={'span'} /> Actual (formatted)const Main=({thing:a='div'})=>React.createElement(Thing,null); // ReferenceError Thing is not defined
React.createElement(Main,{thing:'span'}); Expected (formatted)const Main=({thing:A='div'})=>React.createElement(A,null);
React.createElement(Main,{thing:'span'}); |
@keithamus I think this is correct because you shoud write that: const Main = ({ Thing: ThingInterface = 'div' }) => <Thing />;
<Main thing={'span'} /> The |
You're right @xtuc, I've updated my expected to reflect that. The salient point, however, is that the name is mangled but this is not reflected into the rest of the function. It either needs to mangle both or mangle neither; currently it mangles one. |
Tested out the mangler on our codebase and got the following:
converts to
notice the third item in the destructured array is
d
instead ofc
for some reason.I see there are a few mangler bugs filed, but I don't know if this is one of them. Sorry if it is a duplicate.
The text was updated successfully, but these errors were encountered: