fix: migrate derivations without semicolons (#11704)

Closes #11689
pull/11663/head
Paolo Ricciuti 7 months ago committed by GitHub
parent 02520aea48
commit b788b72862
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: migrate derivations without semicolons

@ -369,11 +369,15 @@ const instance_script = {
/** @type {number} */ (node.body.expression.right.start),
'$derived('
);
if (node.body.expression.right.end !== node.end) {
state.str.update(
/** @type {number} */ (node.body.expression.right.end),
/** @type {number} */ (node.end),
');'
);
} else {
state.str.appendRight(/** @type {number} */ (node.end), ');');
}
return;
} else {
for (const binding of reassigned_bindings) {

@ -0,0 +1,7 @@
<script>
let count = 0;
$: doubled = count * 2
$: ({ quadrupled } = { quadrupled: count * 4 })
</script>
{count} / {doubled} / {quadrupled}

@ -0,0 +1,7 @@
<script>
let count = 0;
let doubled = $derived(count * 2);
let { quadrupled } = $derived({ quadrupled: count * 4 });
</script>
{count} / {doubled} / {quadrupled}
Loading…
Cancel
Save