Skip to content

Svelte typecasting where it shouldn't #657

@alindsay55661

Description

@alindsay55661

Svelte is incorrectly casting numeric strings to numbers when assigned to component properties. This results in strange truthy behavior:

"1" is truthy
"true" is truthy
"false" is truthy

"0" is falsey
"0" is falsey

All of these strings should be truthy, but the number (and html entity for 0) are falsey.

https://svelte.technology/repl?version=1.22.5&gist=b75e1acf7ee81e6fb2b6d0ae0e8349d5

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