Skip to content

Allow creating read-only accessors of primitive states #10310

Closed
@Thiagolino8

Description

@Thiagolino8

Describe the problem

In Svelte 3/4 the export keyword had two different meanings within components, create props and create accessors

In Svelte 5 the keyword has only 1 meaning, creating read-only accessors, and if you want to add the ability to write to the accessor the value also needs to be declared as a prop

However, it is not possible to create let variable accessors this way

export let count = $state({value: 0})

only this way

let count = $state({value: 0})
export {count}

And it is also not possible to create state accessors for let variables that are reassigned without also declaring it as a prop

Describe the proposed solution

Allow the use of export let in runes mode for the purpose of creating read-only accessors and allow the creation of read-only accessors for primitive states

Importance

would make my life easier

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions