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

Using default parameters object and destructuring, results in error: Assigning to rvalue #14393

Open
enyo opened this issue Nov 21, 2024 · 2 comments

Comments

@enyo
Copy link

enyo commented Nov 21, 2024

Describe the bug

This code in the typescript block of a svelte component fails:

  const increment = ({ increment } : { increment?: number } = {}) => {
    count += 1
  }

with error Assigning to rvalue svelte(js_parse_error)

Workarounds:

  • Removing the default object
  • Removing the destructuring: (params: { increment?: number } = {})
  • Removing the type annotation: ({ increment } = {})

Reproduction

https://stackblitz.com/edit/vitejs-vite-dcqkxf?file=src%2Flib%2FCounter.svelte%3AL7

Logs

No response

System Info

Latest Svelte 5 version

Severity

annoyance

@Conduitry
Copy link
Member

Likely to be the same sort of thing as #13409, which is blocked by the upstream acorn-typescript, which no longer seems to be maintained, and which we'll probably have to fork and take over maintenance of at some point.

@harrisi
Copy link

harrisi commented Nov 21, 2024

Another workaround, you can use a normal function:

function increment({ increment }: { increment?: number } = {}) {
  count += 1
}

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

3 participants