Skip to content

Svelte 5: Increment(++) and Decrement(--) operator output is incorrect #11501

@fznhq

Description

@fznhq

Describe the bug

in svelte 4 the compiler output it as is (count++, count--)
but in svelte 5 the output is convert to (count + (n or 1))
therefore it does something different, like this:

let plus = $state("0")
++plus // the output should be (1 as number) but it become (01 as string)

let minus = $state("0")
--minus // the output should be (-1 as number) but it become (0-1 as string)

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACnWQwQrCMBBEfyUsHipa9Fyr4HdYD5puIZhuQ7MRJPTfTVJaC-ohgcnM20nioVEaLRQXD3RrEQo4GwNb4JeJwj5RMwZtO9fLeFJa2SvDp4oq1sjCaGfFUaws3xizCvYVrA-T2Sr648bVOJKsOhKKZI8tEmdr4ZPLcexmk6JD2JbpGr_SqSfPp3i5-1ySyrtjDlhHUiv5OPq5bUiPCLIQPvYlckz_JufmkawxgKl6SYbPartaNQprKLh3OFyHNz4tUkFnAQAA

Logs

No response

System Info

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