Skip to content
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

false positive for svelte(state_referenced_locally) when using typeof in generics. #15657

Closed
Hugos68 opened this issue Apr 1, 2025 · 1 comment
Labels

Comments

@Hugos68
Copy link
Contributor

Hugos68 commented Apr 1, 2025

Describe the bug

When using typeof <value> in a generic and that value happens to be something stateful ($state/$derived). The Svelte LSP will warn you about it being referenced locally even though that doesn't apply with generic types.

Reproduction

let count = $state(0);

type Count = typeof count; // Works as expected

function foo<T>() {}

foo<typeof count>(); // Unexpected warning

Image

Expected behaviour

State referenced with typeof in a generic expression should not warn me about locally referenced state

System Info

  • OS: Windows
  • IDE: VSCode

Which package is the issue about?

svelte-language-server, Svelte for VS Code extension

Additional Information, eg. Screenshots

I think the issue is in the language server but since I'm using it through the VSCode extension I flagged it as a VSCode extension issue, feel free to adjust it accordingly.

@Hugos68 Hugos68 added the bug label Apr 1, 2025
@dummdidumm dummdidumm transferred this issue from sveltejs/language-tools Apr 1, 2025
@dummdidumm
Copy link
Member

Fixed through #15659

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants