Fix: Improve each_item_invalid_assignment error message
#14703In runes mode, when iterating an array of objects in an each loop, it is not possible to bind the object to a component.
<svelte:options runes={true} />
<script>
import Component from "./Component.svelte"
let objs = [{
val: "foo"
}]
</script>
{#each objs as obj}
<Component bind:obj />
{/each}
Error each_item_invalid_assignment
is raised. This works fine when runes mode is disabled.
https://svelte.dev/playground/71e6da2a2afd4a5e812bdd7263e5c7dd?version=5.12.0
Cannot reassign or bind to each block argument in runes mode. Use the array and index variables instead (e.g. `array[i] = value` instead of `entry = value`)
https://svelte.dev/e/each_item_invalid_assignment
svelte 5.12.0, see repl
blocking an upgrade
Closes #14702
Latest commit: d3fd53d
Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.
When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types
Click here to learn what changesets are, and how to add one.
Click here if you're a maintainer who wants to add a changeset to this PR
pnpm add https://pkg.pr.new/svelte@14703
Probably edited the wrong file I guess (Playground still shows the old string), was only trying to do a quick ctrl+f before heading out.
Edit: correct place is here if anyone wants to change that https://github.com/sveltejs/svelte/blob/af9b071622e5c9e3d57a62c78adb6ed8deafeb53/packages/svelte/src/compiler/errors.js#L159