sveltejs / language-tools

The Svelte Language Server, and official extensions which use it
MIT License
1.26k stars 202 forks source link

`derived` and `$derived` cause lsp error #2605

Open Pandoks opened 4 days ago

Pandoks commented 4 days ago

Describe the bug

When you import derived from svelte/store, it seems like $derived breaks the lsp. image

Reproduction

Use derived from svelte/store in the same file as $derived

Logs

No response

System Info

System:
    OS: macOS 15.1.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 13.46 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.5.0 - ~/.nvm/versions/node/v20.5.0/bin/node
    npm: 10.3.0 - ~/.nvm/versions/node/v20.5.0/bin/npm
    pnpm: 9.9.0 - ~/.nvm/versions/node/v20.5.0/bin/pnpm
    bun: 1.1.36 - /opt/homebrew/bin/bun
    Watchman: 2024.11.18.00 - /opt/homebrew/bin/watchman
  Browsers:
    Brave Browser: 131.1.73.91
    Safari: 18.1.1
  npmPackages:
    svelte: ^5.2.7 => 5.2.7

Severity

annoyance

nmzein commented 4 days ago

I might be wrong but I don't think theyre supposed to be used together in one file. What's stopping you from using a derived rune for the bottom example as well?

Pandoks commented 4 days ago

I might be wrong but I don't think theyre supposed to be used together in one file. What's stopping you from using a derived rune for the bottom example as well?

I was using superforms and I'm trying to synchronize the stores that are produced by it. I have other states and derived variables going on too. It'll probably be fixed as svelte deprecates more features, but for now it's kind of annoying. The code works though, but the dev exp is just really bad. See red everywhere.

nmzein commented 4 days ago

Yeah but you should be able to synchronise stores with $derived

Pandoks commented 4 days ago

Yeah but you should be able to synchronise stores with $derived

oh i didn't even know that. there should be more info on migrating stores to runes. i know it's technically not a fully deprecated feature, but there isn't many examples of using stores together with runes. i thought if you used stores, you have to strictly use the stores api

nmzein commented 2 days ago

Yeah should prob be better documented but stores are fully compatible with the new runes stuff so you can use them in all runes including state, derived and effect. This is useful because it makes things like dealing with SvelteKit stuff that hasnt been migrated to runes yet easier without having to use deprecated apis