Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/svelte/src/compiler/migrate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ const instance_script = {
);
const bindings = ids.map((id) => state.scope.get(id.name));
const reassigned_bindings = bindings.filter((b) => b?.reassigned);
if (reassigned_bindings.length === 0 && !bindings.some((b) => b?.kind === 'store_sub')) {
if (reassigned_bindings.length === 0 && !bindings.some((b) => b?.kind === 'store_sub') && node.body.expression.left.type === "Identifier") {
let { start, end } = /** @type {{ start: number, end: number }} */ (
node.body.expression.right
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
// no semicolon at the end
$: time_8 = count * 8
$: ({ time_16 } = { time_16: count * 16 })
// preceeding let that doesn't do anything
let time_32;
$: time_32 = count * doubled;
let very_high;
$: very_high = time_32 * count;
</script>

{count} / {doubled} / {quadrupled} / {time_8} / {time_16}
3 changes: 3 additions & 0 deletions packages/svelte/tests/migrate/samples/effects/input.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
console.log('bar');
}
$: $count = 1;
$: $count.x = count;
</script>

<button onclick={() => count++}>increment</button>
4 changes: 3 additions & 1 deletion packages/svelte/tests/migrate/samples/effects/output.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@
run(() => {
$count = 1;
});
</script>
</script>

<button onclick={() => count++}>increment</button>