-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly migrate sequence expressions (#13291)
* fix: correctly migrate sequence expressions * remove unwanted parens --------- Co-authored-by: Rich Harris <rich.harris@vercel.com>
- Loading branch information
1 parent
09527fd
commit e3c56fa
Showing
8 changed files
with
69 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'svelte': patch | ||
--- | ||
|
||
fix: correctly migrate sequence expressions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 0 additions & 7 deletions
7
packages/svelte/tests/migrate/samples/derivations-no-colon/input.svelte
This file was deleted.
Oops, something went wrong.
7 changes: 0 additions & 7 deletions
7
packages/svelte/tests/migrate/samples/derivations-no-colon/output.svelte
This file was deleted.
Oops, something went wrong.
6 changes: 5 additions & 1 deletion
6
packages/svelte/tests/migrate/samples/derivations/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
<script> | ||
let count = 0; | ||
// semicolon at the end | ||
$: doubled = count * 2; | ||
$: ({ quadrupled } = { quadrupled: count * 4 }); | ||
// no semicolon at the end | ||
$: time_8 = count * 8 | ||
$: ({ time_16 } = { time_16: count * 16 }) | ||
</script> | ||
|
||
{count} / {doubled} / {quadrupled} | ||
{count} / {doubled} / {quadrupled} / {time_8} / {time_16} |
6 changes: 5 additions & 1 deletion
6
packages/svelte/tests/migrate/samples/derivations/output.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
<script> | ||
let count = 0; | ||
// semicolon at the end | ||
let doubled = $derived(count * 2); | ||
let { quadrupled } = $derived({ quadrupled: count * 4 }); | ||
// no semicolon at the end | ||
let time_8 = $derived(count * 8) | ||
let { time_16 } = $derived({ time_16: count * 16 }) | ||
</script> | ||
|
||
{count} / {doubled} / {quadrupled} | ||
{count} / {doubled} / {quadrupled} / {time_8} / {time_16} |
14 changes: 14 additions & 0 deletions
14
packages/svelte/tests/migrate/samples/state-and-derivations-sequence/input.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script> | ||
let count = (void 0, 0); | ||
// semicolon at the end | ||
$: doubled = (void 0, count * 2); | ||
$: ({ quadrupled } = (void 0, { quadrupled: count * 4 })); | ||
// no semicolon at the end | ||
$: time_8 = (void 0, count * 8) | ||
$: ({ time_16 } = (void 0, { time_16: count * 16 })) | ||
</script> | ||
|
||
<!-- reassign to migrate to state --> | ||
<button onclick={()=> count++}></button> | ||
|
||
{count} / {doubled} / {quadrupled} / {time_8} / {time_16} |
14 changes: 14 additions & 0 deletions
14
packages/svelte/tests/migrate/samples/state-and-derivations-sequence/output.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<script> | ||
let count = $state((void 0, 0)); | ||
// semicolon at the end | ||
let doubled = $derived((void 0, count * 2)); | ||
let { quadrupled } = $derived((void 0, { quadrupled: count * 4 })); | ||
// no semicolon at the end | ||
let time_8 = $derived((void 0, count * 8)) | ||
let { time_16 } = $derived((void 0, { time_16: count * 16 })) | ||
</script> | ||
|
||
<!-- reassign to migrate to state --> | ||
<button onclick={()=> count++}></button> | ||
|
||
{count} / {doubled} / {quadrupled} / {time_8} / {time_16} |