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

What about static.foo instead of class.foo? #3

Open
hax opened this issue Jul 20, 2020 · 3 comments
Open

What about static.foo instead of class.foo? #3

hax opened this issue Jul 20, 2020 · 3 comments

Comments

@hax
Copy link
Member

hax commented Jul 20, 2020

It seems static.foo may be a little bit easier to understand because it just map the static foo declaration.

@hax
Copy link
Member Author

hax commented Jul 20, 2020

Another benefit may be it could provide a way to refer the class, for example new static.

@ljharb
Copy link
Member

ljharb commented Jul 20, 2020

Concerns brought up around this are that static is a valid identifier in sloppy mode, and is currently an error inside class bodies, since they're auto-strict:

let static = { x: 1 };
class C {
  static x = 2;
  static y = static.x;
}
C.y // 1, 2, or "threw before evaluating this line"?

This currently throws; with this proposal using static., it would produce 2, but a user might expect it to produce 1, which would be confusing.

@hax
Copy link
Member Author

hax commented Jul 21, 2020

Yeah, it bring ambiguity in sloppy mode, but I would argue that it won't be worse than the similar issues of await/yield. 😂

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

No branches or pull requests

2 participants