Skip to content

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

@Hugos68

Description

@Hugos68

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions