Skip to content

Svelte 5: Confusing and unclear warning state_referenced_locally #11883

Closed
@qupig

Description

@qupig

Describe the bug

State referenced in its own scope will never update. Did you mean to reference it inside a closure? (state_referenced_locally)

What problem was this warning intended to avoid in the first place?
Why does it always appear in confusing and unclear places?

In the slightly modified official documentation example below, everything works fine and I don't understand what the warning means.

Possibly related issues: #9857 #10905

Reproduction

Svelte5-REPL

Logs

No response

System Info

svelte@5.0.0-next.148

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions