tc39 / proposal-call-this

A proposal for a simple call-this operator in JavaScript.
https://tc39.es/proposal-call-this/
MIT License
121 stars 5 forks source link

Should we allow PrivateIdentifier after . in SimpleMemberExpression? #20

Closed JLHwung closed 2 years ago

JLHwung commented 2 years ago

The current syntax

SimpleMemberExpression[Yield, Await] :
  IdentifierReference[?Yield, ?Await]
  SimpleMemberExpression[?Yield, ?Await] . IdentifierName
  ( Expression[+In, ?Yield, ?Await] )

disallows o.#p as a simple member expression, instead one would have to parenthesize it into (o.#p).

Is it intentional? From users's perspective, I would expect it suffices to replace .foo with .#foo when transitioning from a public property to a private one.

js-choi commented 2 years ago

I agree; I think that we should allow rec::obj.#fn. I will amend the proposal when I have time.

This is a cross-cutting concern with decorators’ syntax, with which bind-this shares. @obj.#fn class {} should also be valid; it may be worth opening an issue there about this too.