Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorators on getter/setter ignores implementation, allows duplicates #4450

Open
Tracked by #2964
wjhsf opened this issue Aug 8, 2024 · 2 comments
Open
Tracked by #2964

Decorators on getter/setter ignores implementation, allows duplicates #4450

wjhsf opened this issue Aug 8, 2024 · 2 comments

Comments

@wjhsf
Copy link
Contributor

wjhsf commented Aug 8, 2024

class Component extends LightningElement {
  @wire(getBook, {id: 1}) get book1 () {
    console.log('getter')
  }
  @wire(getBook, {id: 2}) set book2(v) {
    console.log('setter')
  }
}

Currently, the compiler treats getters and setters identically to props; the implementations present on a component are dropped. (In the example above, neither 'getter' nor 'setter' are ever logged to console.) This behavior is not obvious, but using @wire on a getter/setter is also kind of weird. (A getter cannot receive data, so decorating it with a data provider doesn't really make sense.) To make the behavior more consistent with expectations, we should either disallow @wire on a getter/setter, or we should preserve their implementations. In either case, it would be a breaking change.

@nolanlawson nolanlawson changed the title @wire on getter/setter ignores implementation @wire on getter/setter ignores implementation, allows duplicates Dec 9, 2024
@nolanlawson
Copy link
Collaborator

I am going to cram all the decorator-related issues with getters/setters into this issue. In short:

  • We allow duplicate props/methods/getters/setters when we should throw an error at compile time instead
  • Getters/setters are not actually supported and just become props at runtime

@nolanlawson nolanlawson changed the title @wire on getter/setter ignores implementation, allows duplicates Decorators on getter/setter ignores implementation, allows duplicates Dec 9, 2024
@nolanlawson
Copy link
Collaborator

As a first step, we should probably just warn on duplicates. This is low-to-zero-risk.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants