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

Behavior of #each destructure with trailing commas #4810

Closed
GrygrFlzr opened this issue May 9, 2020 · 3 comments
Closed

Behavior of #each destructure with trailing commas #4810

GrygrFlzr opened this issue May 9, 2020 · 3 comments
Labels

Comments

@GrygrFlzr
Copy link
Member

Is your feature request related to a problem? Please describe.
Currently, when destructuring in an #each block with a trailing comma like this:

{#each list as {first, last, }}

The following error is spit out:

Not implemented Empty

(see this repl for an example)

Describe the solution you'd like
Allow for comma trails when destructuring in an #each block. This is consistent with JS object destructure notation, which supports this:

let obj = {x: 1, y: 2};
let {
  x,
  y,
} = obj;
console.log(x, y); // prints "1 2"

Describe alternatives you've considered
Have a clearer error message explaining that trailing commas are not supported. The current Not implemented Empty can lead to some hair-tearing situations, even if svelte decides to not support trailing commas in #each blocks.

How important is this feature to you?
Minor priority.

Additional context
This was brought up in the discord after someone encountered this particular issue.

@GrygrFlzr
Copy link
Member Author

Also notable, in SSR mode a similarly vague error is produced:

Cannot read property '0' of null

@Conduitry Conduitry added the bug label May 10, 2020
@Conduitry
Copy link
Member

This would be fixed by #4596 but unfortunately that PR needs a little more work because of changes that have happened in master in the meantime.

@Conduitry
Copy link
Member

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

No branches or pull requests

2 participants