Skip to content

Svelte ignores new this bindings regarding private class fields declared with $state #15682

Open
@Ocean-OS

Description

@Ocean-OS

Describe the bug

Found this issue while working on #15673. Basically, if you have a function (or other thing that adds a new this binding without being a class) inside of a class method, Svelte will still wrap any private property access with $.get/$.set.
I feel like accessing private properties inside this scopes that aren't classes should probably be a syntax error, but if not, at least this should be fixed. I put in a check for this in the code for $state.invalidate, so it shouldn't be too hard to fix for everything else.

Reproduction

REPL link

Logs

System Info

N/A

Severity

annoyance

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