svelte icon indicating copy to clipboard operation
svelte copied to clipboard

Binding to an exported constant while passing `$$restProps` fails

Open sockmaster27 opened this issue 1 year ago • 2 comments

Describe the bug

Running the Svelte 5 compiler on the program linked in the reproduction fails with the error can't overwrite accessor property "x". This is annoying since it worked in Svelte 4, and it's hard to pinpoint the cause of this error when doing an incremental adoption of the new syntax.

Reproduction

https://svelte.dev/playground/f3fedf8d01d54d21bdaa924417649d5b?version=5.0.5

Logs

No response

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
    Memory: 5.18 GB / 15.92 GB
  Binaries:
    Node: 20.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.0 - C:\Program Files\nodejs\npm.CMD
    bun: 1.1.12 - ~\.bun\bin\bun.EXE
  Browsers:
    Chrome: 130.0.6723.59
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.3527

Severity

annoyance

sockmaster27 avatar Oct 23 '24 19:10 sockmaster27

This is because you are exporting const instead of let...i'm assuming you wanted to export let otherwise this is one of the documented breaking changes

https://svelte.dev/docs/svelte/v5-migration-guide#Breaking-changes-in-runes-mode-Bindings-to-component-exports-are-not-allowed

paoloricciuti avatar Oct 23 '24 20:10 paoloricciuti

This is not in runes mode though. I'm just trying to compile a Svelte 4 project using the new compiler.

sockmaster27 avatar Oct 23 '24 20:10 sockmaster27