Skip to content

Fix deferred export of array binding pattern #10798

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

Merged
merged 1 commit into from
Sep 9, 2016
Merged

Fix deferred export of array binding pattern #10798

merged 1 commit into from
Sep 9, 2016

Conversation

rbuckton
Copy link
Member

@rbuckton rbuckton commented Sep 9, 2016

We parse the missing element as an OmittedExpression but cast it to a BindingElement even though it does not have the same shape. The result was an issue where the module transformer did not account for this case and code like the following would result in an exception:

const [a, , b] = [1, 2, 3];
export { a, b };

This PR makes the expected types more explicit and fixes the incorrect case.

Fixes #10778

export function isArrayBindingElement(node: Node): node is ArrayBindingElement {
const kind = node.kind;
return kind === SyntaxKind.BindingElement
|| kind === SyntaxKind.OmittedExpression;
Copy link
Member

Choose a reason for hiding this comment

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

It's kind of weird that a binding element uses an omitted expression

@DanielRosenwasser
Copy link
Member

Looks good to me 👍

@rbuckton rbuckton merged commit 6b25dab into master Sep 9, 2016
@rbuckton rbuckton deleted the fix10778 branch September 9, 2016 02:49
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nightly error
3 participants