language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

`derived` and `$derived` cause lsp error

Open Pandoks opened this issue 1 year ago • 5 comments

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

Pandoks avatar Nov 25 '24 06:11 Pandoks

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?

nmzein avatar Nov 25 '24 07:11 nmzein

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.

Pandoks avatar Nov 25 '24 08:11 Pandoks

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

nmzein avatar Nov 25 '24 08:11 nmzein

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

Pandoks avatar Nov 25 '24 15:11 Pandoks

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

nmzein avatar Nov 27 '24 11:11 nmzein

Fixed in language-server 0.17.16 and svelte-check 4.2.2

jasonlyu123 avatar Aug 11 '25 03:08 jasonlyu123