Skip to content

Commit c051a6e

Browse files
fix: improve error message for migration errors when slot would be renamed (#15841)
Co-authored-by: Paolo Ricciuti <[email protected]>
1 parent 1c2fc21 commit c051a6e

File tree

5 files changed

+13
-8
lines changed

5 files changed

+13
-8
lines changed

.changeset/strong-coins-peel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: improve error message for migration errors when slot would be renamed

packages/svelte/src/compiler/migrate/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,7 +1307,7 @@ const template = {
13071307
name = state.scope.generate(slot_name);
13081308
if (name !== slot_name) {
13091309
throw new MigrationError(
1310-
'This migration would change the name of a slot making the component unusable'
1310+
`This migration would change the name of a slot (${slot_name} to ${name}) making the component unusable`
13111311
);
13121312
}
13131313
}
@@ -1880,7 +1880,7 @@ function handle_identifier(node, state, path) {
18801880
let new_name = state.scope.generate(name);
18811881
if (new_name !== name) {
18821882
throw new MigrationError(
1883-
'This migration would change the name of a slot making the component unusable'
1883+
`This migration would change the name of a slot (${name} to ${new_name}) making the component unusable`
18841884
);
18851885
}
18861886
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable -->
1+
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot (derived to derived_1) making the component unusable -->
22
<script>
33
let derived;
44
</script>
55
<Component>
66
<slot name="derived" slot="derived" />
7-
</Component>
7+
</Component>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable -->
1+
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot (body to body_1) making the component unusable -->
22
<script>
33
let body;
44
</script>
55

6-
<slot name="body"></slot>
6+
<slot name="body"></slot>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable -->
2-
<slot name="dashed-name"></slot>
1+
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot (dashed-name to dashed_name) making the component unusable -->
2+
<slot name="dashed-name"></slot>

0 commit comments

Comments
 (0)