-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Describe the bug
I'm so happy to see Svelte 5 finally out the door. Great job everyone involved!
I have been trying to familiarise myself with how runes work. More specifically how you would build something that enables reuse of reactive things. In doing so I almost immediately stumbled upon this issue, and it took me quite some time to even figure out what was wrong.
If count refers to a $state rune exposed by counter, this will work:
const c = counter();
$inspect(c.count);And that will silently fail when the state is updated:
const { count } = counter();
$inspect(count);Maybe the reason for this is obvious if you know how this is implemented under the hood, but for me this completely breaks my mental model for what's safe to do or not. If the destructuring case can't be fixed for whatever reason, then some sort of linting rule or compiler warning (like for other rune foot guns) would help a lot! A mention in the docs wouldn't hurt either.
Reproduction
https://svelte.dev/playground/a38340b5fd194cc685de720ed613c0e6?version=5.1.2
System Info
Svelte version 5.1.2Severity
annoyance