Skip to content

Automatic class string coercion is not reactive #15289

Open
@rChaoz

Description

@rChaoz

Describe the bug

Considering this code:

class Test {
	thing = $state(0)
	toString() {
		return String(this.thing)
	}
}

const test = new Test()

Using {test} in the component template is not reactive (when thing changes), but {String(test)} is.

Reproduction

https://svelte.dev/playground/e44b1258b39c4477a38ccb9ecaa4cd21?version=5.20.0

annoyance

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions