mirror of https://github.com/sveltejs/svelte
parent
b665425e5d
commit
6695a5eec9
@ -0,0 +1,5 @@
|
||||
---
|
||||
'svelte': patch
|
||||
---
|
||||
|
||||
feat: support migration of single assignment labeled statements
|
@ -0,0 +1,49 @@
|
||||
<script>
|
||||
let count = 0;
|
||||
let double;
|
||||
$:{
|
||||
double = count * 2;
|
||||
}
|
||||
|
||||
let quadruple;
|
||||
$:{
|
||||
quadruple = count * 4;
|
||||
console.log("i have a side effect")
|
||||
}
|
||||
|
||||
let eight_times;
|
||||
$:{
|
||||
// updated
|
||||
eight_times = count * 8;
|
||||
}
|
||||
|
||||
let sixteen_times;
|
||||
$:{
|
||||
// reassigned outside labeled statement
|
||||
sixteen_times = count * 16;
|
||||
}
|
||||
|
||||
let alot_times;
|
||||
$:{
|
||||
// reassigned in multiple labeled
|
||||
alot_times = count * 32;
|
||||
}
|
||||
$:{
|
||||
// reassigned in multiple labeled
|
||||
alot_times = count * 32;
|
||||
}
|
||||
|
||||
let evenmore;
|
||||
let evenmore_doubled;
|
||||
$:{
|
||||
// multiple stuff in label
|
||||
evenmore = count * 64;
|
||||
evenmore_doubled = evenmore * 2;
|
||||
}
|
||||
</script>
|
||||
|
||||
<button on:click={()=>{
|
||||
count++;
|
||||
eight_times++;
|
||||
sixteen_times += 1;
|
||||
}}>click</button>
|
@ -0,0 +1,49 @@
|
||||
<script>
|
||||
import { run } from 'svelte/legacy';
|
||||
|
||||
let count = $state(0);
|
||||
let double = $derived(count * 2);
|
||||
|
||||
|
||||
let quadruple = $state();
|
||||
run(() => {
|
||||
quadruple = count * 4;
|
||||
console.log("i have a side effect")
|
||||
});
|
||||
|
||||
let eight_times = $state();
|
||||
run(() => {
|
||||
// updated
|
||||
eight_times = count * 8;
|
||||
});
|
||||
|
||||
let sixteen_times = $state();
|
||||
run(() => {
|
||||
// reassigned outside labeled statement
|
||||
sixteen_times = count * 16;
|
||||
});
|
||||
|
||||
let alot_times = $state();
|
||||
run(() => {
|
||||
// reassigned in multiple labeled
|
||||
alot_times = count * 32;
|
||||
});
|
||||
run(() => {
|
||||
// reassigned in multiple labeled
|
||||
alot_times = count * 32;
|
||||
});
|
||||
|
||||
let evenmore = $state();
|
||||
let evenmore_doubled = $state();
|
||||
run(() => {
|
||||
// multiple stuff in label
|
||||
evenmore = count * 64;
|
||||
evenmore_doubled = evenmore * 2;
|
||||
});
|
||||
</script>
|
||||
|
||||
<button onclick={()=>{
|
||||
count++;
|
||||
eight_times++;
|
||||
sixteen_times += 1;
|
||||
}}>click</button>
|
Loading…
Reference in new issue