Skip to content

Computed property names in Svelte each block destructuring #487

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

Open
hyunbinseo opened this issue Feb 24, 2025 · 0 comments
Open

Computed property names in Svelte each block destructuring #487

hyunbinseo opened this issue Feb 24, 2025 · 0 comments

Comments

@hyunbinseo
Copy link
Contributor

When using computed property names ([id]) in Svelte's each block destructuring pattern, the square brackets are removed.

- {#each objs as { [id]: value }}
+ {#each objs as { id: value }}

This causes a syntax error:

<script lang="ts">
  const ids = ['a', 'b', 'c'] as const;
  const objs = [{ a: 1 }, { b: 2 }, { c: 3 }];
</script>

{#each ids as id}
  <tr>
    <!-- Property 'id' does not exist on type (…) -->
    {#each objs as { id: value }}
      <td>{value}</td>
    {/each}
  </tr>
{/each}
devDependencies:
prettier 3.5.2
prettier-plugin-svelte 3.3.3
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