Open HighFunctioningSociopathSH opened 1 week ago
This is intended When you have a variable with a particular name, the rune with that name is automatically disabled, to allow for the store subscription syntax
That is, svelte can't make sure state
is not a store, and reserves $state
for the case it is one, and so that rune is automatically turned off
if so then maybe it should show a better error message that is less confusing. perhaps something that tells the user to avoid using variables with these names at runes mode. And perhaps change the names in the docs as well to avoid confusion.
Describe the bug
a variable named "state" or "derived" can cause typescript to show error if the $state or $derived runes are used before that variable.
Reproduction
In the docs I ran into the following code:
After trying to use it, I got an error and apparently its because I had used $state before. so the following code:
will show an error saying "Block-scoped variable '$state' used before its declaration." or "Block-scoped variable '$derived' used before its declaration." It goes away if you change the name of the "state" or "derived" variables to something else. Svelte for VS code is on version 109.1.0
Logs
No response
System Info
Severity
annoyance