Skip to content

[Svelte 5] Literal 0 (zero) cannot be set as prop without giving it any default #10854

@harrisi

Description

@harrisi

Describe the bug

If a component exposes a literal 0 (zero) as a prop, it cannot be set by the parent without setting a default value (even of undefined).

One alternative is to just use a string representation (i.e., '0'), but it's odd that this doesn't work for 0 but does for other numbers.

The compiled code is odd - it's like it's treating 0 as special, even though it's actually receiving the string representation - '0'.

Reproduction

repl

Logs

No response

System Info

repl

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