fix: improve error message for migration errors when slot would be renamed (#15841)

Co-authored-by: Paolo Ricciuti <ricciutipaolo@gmail.com>
pull/15861/head
Lars Francke 4 months ago committed by GitHub
parent 1c2fc21023
commit c051a6eb1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: improve error message for migration errors when slot would be renamed

@ -1307,7 +1307,7 @@ const template = {
name = state.scope.generate(slot_name); name = state.scope.generate(slot_name);
if (name !== slot_name) { if (name !== slot_name) {
throw new MigrationError( throw new MigrationError(
'This migration would change the name of a slot making the component unusable' `This migration would change the name of a slot (${slot_name} to ${name}) making the component unusable`
); );
} }
} }
@ -1880,7 +1880,7 @@ function handle_identifier(node, state, path) {
let new_name = state.scope.generate(name); let new_name = state.scope.generate(name);
if (new_name !== name) { if (new_name !== name) {
throw new MigrationError( throw new MigrationError(
'This migration would change the name of a slot making the component unusable' `This migration would change the name of a slot (${name} to ${new_name}) making the component unusable`
); );
} }
} }

@ -1,7 +1,7 @@
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable --> <!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot (derived to derived_1) making the component unusable -->
<script> <script>
let derived; let derived;
</script> </script>
<Component> <Component>
<slot name="derived" slot="derived" /> <slot name="derived" slot="derived" />
</Component> </Component>

@ -1,6 +1,6 @@
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable --> <!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot (body to body_1) making the component unusable -->
<script> <script>
let body; let body;
</script> </script>
<slot name="body"></slot> <slot name="body"></slot>

@ -1,2 +1,2 @@
<!-- @migration-task Error while migrating Svelte code: This migration would change the name of a slot making the component unusable --> <!-- @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 -->
<slot name="dashed-name"></slot> <slot name="dashed-name"></slot>

Loading…
Cancel
Save