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

Exporting a const spread results in undefined #473

Closed
cwohlman opened this issue Oct 31, 2019 · 0 comments · Fixed by #564
Closed

Exporting a const spread results in undefined #473

cwohlman opened this issue Oct 31, 2019 · 0 comments · Fixed by #564
Assignees

Comments

@cwohlman
Copy link

Just ran into an odd bug, apparently exporting a const from an object spread doesn't work. I'm not quite sure why, but I noticed in the compiled source there's a duplicate const declaration (which I thought would be a syntax error).

Basic bug:

const { a } = { a: {} }
export { a } // a will be undefined when imported anywhere

Reproduction: https://github.com/cwohlman/sucrase-stomp-export-reproduction

@alangpierce alangpierce self-assigned this Dec 1, 2020
alangpierce added a commit that referenced this issue Dec 1, 2020
Fixes #563
Fixes #473

The type-only export elision implemented in #433 had a false positive for
destructure delcarations, since `getDeclarationInfo` only looks at top-level
declarations and top-level expressions like `const {x} = ...` weren't being
marked correctly. To fix, we can mark object shorthand declarations as top-level
when applicable. I also refactored both relevant code paths to avoid the
repeated assignment left-hand side.
alangpierce added a commit that referenced this issue Dec 2, 2020
Fixes #563
Fixes #473

The type-only export elision implemented in #433 had a false positive for
destructure delcarations, since `getDeclarationInfo` only looks at top-level
declarations and top-level expressions like `const {x} = ...` weren't being
marked correctly. To fix, we can mark object shorthand declarations as top-level
when applicable. I also refactored both relevant code paths to avoid the
repeated assignment left-hand side.
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

Successfully merging a pull request may close this issue.

2 participants