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

[@babel/parser@7.12.1]: unexpected SyntaxError omitted from function params destructuring #12195

Closed
shhider opened this issue Oct 16, 2020 · 3 comments · Fixed by #12198
Closed
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@shhider
Copy link

shhider commented Oct 16, 2020

Bug Report

Common object deconstruction code:

interface ISomeObj {
  prop1: string;
  prop2: string;
}

const clone = (
  { prop1, prop2 }: ISomeObj,
): ISomeObj => ({ prop1, prop2 });

but babel/parser@7.12.1:

/repl.ts: Unexpected token (8:0)

  6 | const clone = (
  7 |   { prop1, prop2 }: ISomeObj,
> 8 | ): ISomeObj => ({ prop1, prop2 });
    | ^
  9 | 

You can try it in babel website Try It Out.

And,

There is no error if param has only one prop:

interface ISomeObj {
  prop1: string;
  prop2: string;
}

const clone = (
  { prop1 }: ISomeObj,
): ISomeObj => ({ prop1 });

This bug blocks my development, please fix it ASAP.

@babel-bot
Copy link
Collaborator

Hey @shhider! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@babel babel deleted a comment from personalZhang Oct 16, 2020
@shhider shhider changed the title [@babel/parser@7.12.1]: unexpected SyntaxError omitted [@babel/parser@7.12.1]: unexpected SyntaxError omitted from function params destructuring Oct 16, 2020
@nicolo-ribaudo
Copy link
Member

I reverted the commit that introduced the regression and released it as @babel/parser@7.12.2.

@shhider
Copy link
Author

shhider commented Oct 16, 2020

Appreciate!

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Jan 16, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
4 participants