Often times, when I use a class field a lot, I create a local binding for it, 
so that I don't have to prefix every appearance with `this.`:

```js
class Foo {
        bar = 1;
        method() {
                const { bar } = this;
                /* … */
        }
}
```

The same approach would currently be illegal syntax if `bar` is declared to be 
private:

```js
class Foo {
        #bar = 1;
        method() {
                const { #bar } = this;
                /* … */
        }
}
```

How is the destructuring assignment supposed to behave anyway? Introduce a 
local `bar` binding, just like above?

Whatever it should do, even defining an explicit name for the binding is 
currently illegal:

```js
class Foo {
        #bar = 1;
        method() {
                const { #bar: bar } = this;
                /* … */
        }
}
```

This feels really asymmetric to public fields and has come up in the class 
fields proposal[1] before, though it was suggested to defer it to a separate 
proposal.

Is someone currently working on said proposal?

[1] https://github.com/tc39/proposal-class-fields/issues/4

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to