Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Class $state properties auto-reserve #name properties #14364

@lukeed

Description

@lukeed

Describe the bug

Input

class Repo {
  tree = $state();
  async #tree() {
    // load it
  }
}

Output

NOTE: In browser console only

SyntaxError: Identifier '#tree' has already been declared
// generated
{ 
  // ...
  #tree = $.state();

  get tree() {
    return $.get(this.#tree);
  }

  set tree(value) {
    $.set(this.#tree, $.proxy(value, null, this.#tree));
  }
}

Two ideal fixes/outcomes:

  1. devtools (compiler + vscode extension) would have told me #tree is reserved at time of authoring
  2. the generated code uses something like #__tree instead.

Reproduction

included above

Logs

System Info

npmPackages:
    svelte: ^5.0.5 => 5.0.5

Severity

annoyance

Metadata

Metadata

Assignees

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