Skip to content

Conversation

@paoloricciuti
Copy link
Member

@paoloricciuti paoloricciuti commented Nov 7, 2024

Closes #14215

As usual with the migration script you start simple and then you realise new edge cases. This started simply with a state variable erroring when migrating to $state. Then i realised the same could be true for $derived and $props and $bindable.

There are some false negative here: technically this is migratable

<script>
    export let props;
</script>

because

<script>
    let { props } = $props();
</script>

is valid but while with props is probably fine trying to migrate when the binding is in the expression that we are migrating is a lot more complex for derived for example (because we create some new derived in some cases and we don't have a node for that. But i would say this is still good enough and better have some false negative for an edge case than migrate something that can break imho.

There are a lot of tests but that's because i couldn't test multiple things in the same test :(

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2024

Playground

pnpm add https://pkg.pr.new/svelte@14216

@changeset-bot
Copy link

changeset-bot bot commented Nov 8, 2024

🦋 Changeset detected

Latest commit: 9a575e6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dummdidumm dummdidumm merged commit 438de04 into main Nov 8, 2024
11 checks passed
@dummdidumm dummdidumm deleted the migrate-conflict-runes branch November 8, 2024 10:18
@github-actions github-actions bot mentioned this pull request Nov 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

svelte-migrate breaks on local variable called state

3 participants