Skip to content

Static support for $state in .svelte.ts #14804

Open
@Bilge

Description

@Bilge

Describe the problem

I have a class that is entirely static (only static properties and methods). I cannot declare a $state property, either with a field initializer or in a static initialization block. In both cases, Svelte complains that:

_Error: CompileError: state_invalid_placement: $state(...) can only be used as a variable declaration initializer or a class field

Of course, this is a class field, it's just that it's a static field, which seems to be unsupported for some reason.

Describe the proposed solution

Support static class fields.

Importance

would make my life easier

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