sveltejs / svelte

web development for the rest of us
https://svelte.dev
MIT License
80.14k stars 4.26k forks source link

Support for object-rest in each destructuring #2647

Closed mindrones closed 5 years ago

mindrones commented 5 years ago

It'd be nice to be able to do:

{#each sections as {type, ...props}}
  <svelte:component this={foo[type]} {...props} />
{/each}

as an alternative to:

{#each sections as section}
  <svelte:component this={foo[section.type]} {...section} />
{/each}
EmilTholin commented 5 years ago

That would be really nice. I think it can be supported by extending read_context to understand the rest syntax and extending unpack_desctructuring to take a new RestPattern into consideration.

A new Bublé-esque objectWithoutProperties helper function might be needed.