Closed as not planned
Description
Describe the bug
Since Svelte pushes for the use of JS classes, it seems like I would also want to be able to spread them as I do with objects. Currently, it just doesn't work. There are workarounds, such as arrow functions or .bind(this)
(examples in the REPL). Would like clarification on whether any of these methods are recommended.
<script>
import Child from './Child.svelte'
class Counter {
count = $state(0)
constructor(input) {
this.count = input
}
onAdd() {
this.count++
}
}
const counter2 = new Counter(0)
</script>
<h2>❌ spread props</h2>
<Child {...counter2} />
<hr />
Other
Reproduction
Logs
System Info
.
Severity
annoyance
Metadata
Metadata
Assignees
Labels
No labels