Assist with store imports with svelte $ prefix
See original GitHub issueDescription
Regarding the shortcut to directly access store values , https://svelte.dev/docs#component-format-script-4-prefix-stores-with-$-to-access-their-values
A pattern I’ve noticed which has become a sore point over and over is refactoring or writing new code which references a store with the $ prefix. For example, I might write or copy from one component to another…
{#if $showTheThing}
{/if}
However the import is missing so I will click somewhere on $showTheThing to do CTRL + . so that VSCode can import this from the store. This doesn’t provide the hint I want. All I get shown is “(svelte) Disable Missing Declaration for this line”
So then I remove the $ from the string, then do CTRL + . again to import,
{#if showTheThing}
{/if}
Then go back to the beginning of the variable to prepend it back with $
{#if $showTheThing}
{/if}
Proposed solution
I would like to use CTRL + . on $showTheThing and have it suggest the correct import (or even multiple imports at once in the case that many imports are missing).
Alternatives
No response
Additional Information, eg. Screenshots
No response
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:13 (13 by maintainers)
Top GitHub Comments
Guess your local build is still an old version. It did work before but we changed the way we transform the $store variable a while ago to fix some type-checking issues. You can run
yarn bootstrap
to update it.Alrighty, I just linked a PR for this, let me know what you think.