tc39 / proposal-grouped-and-auto-accessors

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

Conflict with static blocks? #4

Closed pzuraq closed 3 years ago

pzuraq commented 3 years ago

So my understanding was that one of the concerns for this proposal was that it would conflict with Static Blocks. I can see one potential conflict, for instance, the following would be a valid static block:

class C {
  static { get; set; }
}

But then adding = at the end would turn it into an auto-accessor:

class C {
  static { get; set; } = 123
}

Is this something we can address in the syntax itself? Is this a use case that is meaningful? Users could probably do:

class C {
  ['static'] { get; set; }
}

If they wanted to define an auto-accessor named static.

nicolo-ribaudo commented 3 years ago

This is no longer an issue, since the proposal includes the explicit accessor prefix:

class A {
  accessor static { get; set; }
}