Skip to content

Migration generates invalid code for $$props #449

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

Closed
ginpei opened this issue Feb 23, 2025 · 3 comments
Closed

Migration generates invalid code for $$props #449

ginpei opened this issue Feb 23, 2025 · 3 comments

Comments

@ginpei
Copy link

ginpei commented Feb 23, 2025

The migration guide says:

all properties: don’t destructure let props = $props();

But the migration tool npx sv migrate svelte-5 converts this code...

<script lang="ts">
  const allProps = $$props;
</script>

... to the code with destructure:

<script lang="ts">
  interface Props {
    [key: string]: any
  }

  let { ...props }: Props = $props();
  const allProps = props;
</script>

It's supposed to be:

  const allProp: Props = $props();
@ginpei
Copy link
Author

ginpei commented Feb 23, 2025

This leads the "p has already been declared" issue (EMH333/esbuild-svelte#260) by the compiler issue (sveltejs/svelte#15375)

@paoloricciuti
Copy link
Member

That issue is probably about esbuild rather than svelte (except probably we can loosen the validation around vars)...but this is perfectly valid code so adding extra code in the migration is really not useful imho. Gonna close this but thanks for reporting

@paoloricciuti paoloricciuti closed this as not planned Won't fix, can't repro, duplicate, stale Feb 23, 2025
@ginpei
Copy link
Author

ginpei commented Feb 23, 2025

I thought destructure was prohibited but found I just misread it. Thanks for the quick response

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

No branches or pull requests

2 participants