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 5 migration: statements should be reordered #12183

Open
Rich-Harris opened this issue Jun 25, 2024 · 0 comments
Open

Svelte 5 migration: statements should be reordered #12183

Rich-Harris opened this issue Jun 25, 2024 · 0 comments
Labels
Milestone

Comments

@Rich-Harris
Copy link
Member

Describe the bug

in:

<script>
  $: mobile = width < 640;
  let width = 0;
</script>

<svelte:window bind:innerWidth={width} />

<p>{mobile ? 'mobile' : 'desktop'}</p>

out:

<script>
  let mobile = $derived(width < 640);
  let width = $state(0);
</script>

<svelte:window bind:innerWidth={width} />

<p>{mobile ? 'mobile' : 'desktop'}</p>

Note that width is referenced before its declaration. This is allowed in Svelte 4 but not in runes mode.

Reproduction

link

Logs

No response

System Info

next

Severity

annoyance

@Rich-Harris Rich-Harris added this to the 5.0 milestone Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant