Skip to content

Default to $state.snapshot() when console logging #15775

Closed as not planned
Closed as not planned
@jamestinman

Description

@jamestinman

Describe the problem

When console logging a reactive variable, the Svelte developer almost always wants to see the value of that variable.

However, in most cases Svelte requires the variable to be wrapped in $state.snapshot() otherwise you only get e.g. [Proxy(Object), Proxy(Object)]. This is unintuitive, and thus IMO going against general Svelteish principles.

Describe the proposed solution

$inspect looked like it was for this use case, but alas itself can only be used inside an effect (e.g. during component initialisation). But still, it would better to default to the obvious console behaviour for the developer, with cases when there is a genuine need to see the variable wrapper perhaps using a different Rune.

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