Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svelte-migrate breaks on local variable called state #14215

Closed
marekdedic opened this issue Nov 7, 2024 · 3 comments · Fixed by #14216
Closed

svelte-migrate breaks on local variable called state #14215

marekdedic opened this issue Nov 7, 2024 · 3 comments · Fixed by #14216

Comments

@marekdedic
Copy link

Describe the bug

Hi,
I have a Svelte 4 file containing a variable called state. When migrating to Svelte 5, this breaks as there is now the variable as well as the $state rune...

I think svelte-migrate should detect this and throw an error...

Reproduction

I don't know how to do repros for svelte-migrate

Logs

No response

System Info

System:
    OS: Linux 6.5 Ubuntu 22.04.5 LTS 22.04.5 LTS (Jammy Jellyfish)
    CPU: (12) x64 12th Gen Intel(R) Core(TM) i7-1265U
    Memory: 5.90 GB / 15.22 GB
    Container: Yes
    Shell: 5.8.1 - /usr/bin/zsh
  Binaries:
    Node: 22.11.0 - /usr/bin/node
    Yarn: 1.22.21 - /usr/bin/yarn
    npm: 10.9.0 - /usr/bin/npm
    pnpm: 8.15.8 - /usr/bin/pnpm
  npmPackages:
    @sveltejs/adapter-static: ^3.0.6 => 3.0.6
    @sveltejs/kit: ^2.8.0 => 2.8.0
    svelte: ^5.0.0 => 5.1.12
    vite: ^5.4.10 => 5.4.10

Severity

annoyance

Additional Information

Probably holds for other rune names.

@paoloricciuti
Copy link
Member

You can still have a variable named state

https://svelte.dev/playground/419dd3d00d3741828923bfa8f50562c1?version=5.1.12

try to migrate this and see that it still works.

You can do this to reproduce for a migration error: paste the code in the playground and share the svelte 4 code (we can then click migrate to verify)

@paoloricciuti
Copy link
Member

You can have a variable named state, but only if you don't use a state rune in the same file (which was the result of my migration):

https://svelte.dev/playground/419dd3d00d3741828923bfa8f50562c1?version=5.1.12#H4sIAAAAAAAAA22OwQ6CMAxAf2U2JmhiJF5xknjzH8TDgCpLxrZsBTWEf7cgiRcvO7z32nUAq1qEDFr9CIpQROIXdnDXBiNk1wHo7adgAsyX_Oz9PvZo5rZUEf_xyllCS7wGZKyC9pQXtiCD9P1GnETydMHUyZH5Yhw1GNis52SzZSXT37SV2vqORKltnfXKdHga5nIUKXvZHPILGuPEQlcyZVRYPofwRZBR6HC8jR-aQYyW-QAAAA==

Gotcha...will fix and by fix mean add a migration task in this case (this should probably be moved to the svelte repo)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants