diff --git a/.changeset/shaggy-seals-judge.md b/.changeset/shaggy-seals-judge.md new file mode 100644 index 0000000000..ef79705c31 --- /dev/null +++ b/.changeset/shaggy-seals-judge.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +fix: prevent migration script from adding `props.` to the `export let` identifier diff --git a/packages/svelte/src/compiler/migrate/index.js b/packages/svelte/src/compiler/migrate/index.js index 057020d730..ceb2ad5da2 100644 --- a/packages/svelte/src/compiler/migrate/index.js +++ b/packages/svelte/src/compiler/migrate/index.js @@ -1514,7 +1514,7 @@ function handle_identifier(node, state, path) { ); } else { const binding = state.scope.get(node.name); - if (binding?.kind === 'bindable_prop') { + if (binding?.kind === 'bindable_prop' && binding.node !== node) { state.str.prependLeft(/** @type {number} */ (node.start), `${state.names.props}.`); } } diff --git a/packages/svelte/tests/migrate/samples/not-prepend-props-to-export-let/input.svelte b/packages/svelte/tests/migrate/samples/not-prepend-props-to-export-let/input.svelte new file mode 100644 index 0000000000..b169f63045 --- /dev/null +++ b/packages/svelte/tests/migrate/samples/not-prepend-props-to-export-let/input.svelte @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/packages/svelte/tests/migrate/samples/not-prepend-props-to-export-let/output.svelte b/packages/svelte/tests/migrate/samples/not-prepend-props-to-export-let/output.svelte new file mode 100644 index 0000000000..8e0f2fd658 --- /dev/null +++ b/packages/svelte/tests/migrate/samples/not-prepend-props-to-export-let/output.svelte @@ -0,0 +1,5 @@ + \ No newline at end of file