svelte
svelte copied to clipboard
svelte 5: unnecessary code generated for updates
Describe the bug
Given code like this...
<script>
let object = $state({ count: 0 });
function increment() {
object.count++;
}
</script>
<button onclick={increment}>
clicks: {object.count}
</button>
...we generate this output:
function increment(_, object) {
(() => {
const $$value = object.count;
object.count += 1;
return $$value;
})();
}
This seems... odd
Reproduction
Logs
No response
System Info
next
Severity
annoyance