tc39 / proposal-grouped-and-auto-accessors

Grouped Accessors and Auto-Accessors for ECMAScript
https://tc39.es/proposal-grouped-and-auto-accessors
MIT License
54 stars 5 forks source link

Should we introduce static grouped and auto accessors? #7

Closed JLHwung closed 2 years ago

JLHwung commented 3 years ago
class C {
  static accessor x {
    get() { ... } // equivalent to `static get x() { ... }`
    set(value) { ... } // equivalent to `static set x(value) { ... }`
  }
  static accessor y = 1; // equivalent to `static accessor y { get; set; } = 1;`
}

The accessors and static are orthogonal class features. I will expect they can be combined together.

rbuckton commented 3 years ago

static accessor ~is~ should already be part of this proposal, as static is applied in ClassElement regardless of the underlying kind of element. ~If that's not clear in the explainer I can add an example.~ My current syntax sketch in the explainer does not correctly illustrate that, so I will update that shortly.

rbuckton commented 2 years ago

The spec text should correctly reflect that static is permitted. I've also updated the explainer with a few examples.