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

Destructuring in export statements doesn't work #297

Closed
alangpierce opened this issue Jul 7, 2018 · 0 comments
Closed

Destructuring in export statements doesn't work #297

alangpierce opened this issue Jul 7, 2018 · 0 comments
Assignees

Comments

@alangpierce
Copy link
Owner

This code:

export const {a, b} = c;

crashes with this error:

Error transforming sample.tsx: Expected a regular identifier after export var/let/const.

Playground link

@alangpierce alangpierce self-assigned this Jul 8, 2018
alangpierce added a commit that referenced this issue Jul 28, 2018
Fixes #297

The export transformation process now finds any declaration on the LHS,
excluding declarations within default values, and modifies them to use `exports`
syntax. In addition, for object destructures, we need to surround the entire
assignment with parens so that it's treated as a proper assignment. This
required some additional parser information: annotating the end index of an `=`
token in more cases, as well as identifying object shorthand declarations.
alangpierce added a commit that referenced this issue Jul 28, 2018
Fixes #297

The export transformation process now finds any declaration on the LHS,
excluding declarations within default values, and modifies them to use `exports`
syntax. In addition, for object destructures, we need to surround the entire
assignment with parens so that it's treated as a proper assignment. This
required some additional parser information: annotating the end index of an `=`
token in more cases, as well as identifying object shorthand declarations.
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

1 participant