svelte icon indicating copy to clipboard operation
svelte copied to clipboard

Svelte 5 migration: erroneous `$state` declaration when `each` block present

Open Rich-Harris opened this issue 7 months ago • 1 comments

Describe the bug

This...

<script>
  const { foo } = x();
</script>

{#each foo as f}{/each}

...gets turned into this by the migrator:

<script lang="ts">
  const { foo } = $state(x());
</script>

{#each foo as f}{/each}

There's no reason for this to be state.

Reproduction

demo

Rich-Harris avatar Jun 24 '24 21:06 Rich-Harris