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

Error with destructuring array within if condition with no braces #152

Closed
brettz9 opened this issue Oct 2, 2018 · 3 comments
Closed

Error with destructuring array within if condition with no braces #152

brettz9 opened this issue Oct 2, 2018 · 3 comments

Comments

@brettz9
Copy link

brettz9 commented Oct 2, 2018

Getting an "Unexpected token" error with code such as the following:

export function replaceRange(from, to) {
  if (from) [from, to] = [to, from]

}

The error doesn't occur if braces are present.

@marijnh
Copy link
Contributor

marijnh commented Oct 2, 2018

Specifically, the generated code looks like this:

export function replaceRange(from, to) {
  var assign;

  if (from) { (assign = [to, from], from = assign[0], to = assign[1] })

}

Which has mismatched brackets (the paren after the destructuring expression ended up before the brace)

@marijnh
Copy link
Contributor

marijnh commented Oct 2, 2018

See PR #153

@adrianheine
Copy link
Member

Fixed with 8117b69.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants