Skip to content

False positive “updated, but not declared with $state” warning #13102

Closed as not planned
@jrmajor

Description

@jrmajor

Describe the bug

With the following code in runes mode:

<script>
	let input;
</script>

{#if true}
	<input bind:this={input}/>
	<button onclick={() => input?.focus()}>focus input</button>
{/if}

I get the following warning: input is updated, but is not declared with $state(...). Changing its value will not correctly trigger updates (non_reactive_update).

This doesn't happen unless the bound element is defined in a conditional.

Reproduction

Here's above example in REPL.

Logs

No response

System Info

System:
  OS: macOS 14.6.1
  CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Memory: 487.38 MB / 16.00 GB
  Shell: 3.7.1 - /usr/local/bin/fish
Binaries:
  Node: 22.7.0 - /usr/local/bin/node
  Yarn: 1.22.22 - /usr/local/bin/yarn
  npm: 10.8.2 - /usr/local/bin/npm
  pnpm: 9.9.0 - /usr/local/bin/pnpm
  bun: 1.1.26 - /usr/local/bin/bun
Browsers:
  Safari: 17.6
npmPackages:
  svelte: 5.0.0-next.242 => 5.0.0-next.242

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions