Closed
Description
The example for initialising state inside a class like described in the docs doesn't work and throws an error
[!] (plugin svelte) CompileError:
$state(...) can only be used as a variable declaration initializer or a class field
export class Todo {
done = $state(false);
text = $state();
constructor(text: string) {
this.text = text;
}
reset() {
this.text = "";
this.done = false;
}
}
Metadata
Metadata
Assignees
Labels
No labels