Skip to content

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

Closed
@enyo

Description

@enyo

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions