Skip to content

Svelte 5: $state declared with var in *.svelte.js broken #12900

@Black1358

Description

@Black1358

Describe the bug

I like to declare states using "var", because they become more noticeable when reading the code. But using this syntax in .svelte.ts files, sometimes the states are "true" when I'm sure they're false. When I output them using console.log, I was very surprised - instead of false, I got the object of the state itself. It definitely wasn't meant to be that way.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACmVSy07EMAz8FSvi0IpVF67d7Up8ACeOFKHSdSFLmlSJuwJV-Xfy6mOFeqhsz9iecSbWcYGGla8Tk02PrGRPw8B2jH4HH5grCkIXGzXq1meOptV8oFMta-L9oDTBBEo-q1GShU6rHupEq5kH3QAJDb2Q0ggLttiHRBE5xcXU7DDzBBK0vjNUcGeoIcwecl91tW6ULXElgctWY4-SshymwKTIua_gMbSykZG2zByuOq1QaZTAQqjPbNmu-ETXLY_kvJbH_apaHj9Gcr2c6Fbw9rualgVscCVkTQlT2MJ6dmScnI-9OvOO45mVpEe0u8X2rQmr_xez9X6RbJyhAgMl45ITb0TSfm00vF8bMeJq2YxIxmmkUctZv1dqZDOYL-Vd7hphcPHRXa6DpZxDosa-xZzP4sBol_8SLKZT1u7i3_h5nr4ZsiwcCjcE66JwPvxJT2ijHexhU_KXpM0Lq25sisIc_v8R3uwf-J-cIQcDAAA=

See dev-console

Logs

Object {
  f: 0,
  v: false,
  reactions: null,
  equals: equals(value),
  version: 0,
}

System Info

Svelte version 5.0.0-next.225

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions