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

Fix treeshaken parameters around parentheses #2911

Merged
merged 1 commit into from Jun 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/ast/nodes/CallExpression.ts
Expand Up @@ -248,7 +248,14 @@ export default class CallExpression extends NodeBase implements DeoptimizableEnt
for (let index = 0; index <= lastIncludedIndex; index++) {
this.arguments[index].render(code, options);
}
code.remove(this.arguments[lastIncludedIndex].end, this.end - 1);
code.remove(
findFirstOccurrenceOutsideComment(
code.original,
',',
this.arguments[lastIncludedIndex].end
),
this.end - 1
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one, I'll take yours 😜

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was a simple enough (and fun) issue to debug! as usual https://astexplorer.net/ was my friend

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is mine as well 😉

} else {
code.remove(
findFirstOccurrenceOutsideComment(code.original, '(', this.callee.end) + 1,
Expand Down
Expand Up @@ -8,3 +8,5 @@ const needed22 = 2;
const needed23 = 3;

someUsedParams(needed21, needed22, needed23);
someUsedParams(needed21, needed22, (needed23));
(someUsedParams)(needed21, needed22, needed23 );
Expand Up @@ -11,3 +11,5 @@ const needed22 = 2;
const needed23 = 3;

someUsedParams(needed21, needed22, needed23, unneeded2);
someUsedParams(needed21, needed22, (needed23), unneeded2);
(someUsedParams)(needed21, needed22, needed23 , unneeded2);