Skip to content

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

Closed
@Rich-Harris

Description

@Rich-Harris

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions