-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
Erroneous "Stores must be declared at the top level of the component" error #5162
Comments
Ah — looks like someone caught this a few days ago Rich-Harris/pancake#19 |
Yeah I tried to solicit input on #5079. It is technically a breaking change, but I'd argue that the code that is now disallowed was confusing. I'd kind of push for changing components that were affected by this, rather than rolling back part of this check. Having a scope where |
Yeah, I guess in this situation we get to decide whether the code is 'valid' or not. For the time being at least I've made the change in pancake. I guess I wouldn't be put out if we closed this accordingly; at least there's an issue to land on if someone searches for the text of the error now. |
Something else I had mentioned on that other PR - if we ever plan to allow subscribing to stores that are not defined at the top-level, that would have itself technically been a breaking change vs. the old behavior. (Because using |
A problem I had was that I wanted to use the values of stores that have been bound by components. The solution for getting the values of the stores is using import { get } from 'svelte/store'
function getValue(store) {
// works
return get(store)
// doesn't work
return $store
}
... I made an example of my use case in a repl: https://svelte.dev/repl/acccf5911f7e41af8025ee88fc005a56?version=3.48.0 |
Closing as |
Describe the bug
Since #5079, valid code is causing the following error:
To Reproduce
https://svelte.dev/repl/8240f1807eda4d429018826229910e48?version=3.24.0
It's coming from this code:
The
y
that is part of the chart context is a store; they
inside the closure is a number.Expected behavior
No error
Severity
Moderate. Requires either downgrading Svelte in our project, or working around the bug in Pancake
The text was updated successfully, but these errors were encountered: