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

Figure out what to do about new JavaScript private member #syntax #94

Open
jattasNI opened this issue Jun 16, 2022 · 2 comments
Open

Figure out what to do about new JavaScript private member #syntax #94

jattasNI opened this issue Jun 16, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@jattasNI
Copy link
Collaborator

The JavaScript feature to set class members as private by prefixing their name with # is now supported in all modern browsers. This issue tracks its impact on our coding conventions.

Things to look into:

  1. do our conventions currently allow the syntax in JS code? Should they?
  2. do our conventions currently allow the syntax in TS code? Should they?
    • TypeScript obviously has its own private member syntax (via the private keyword). We should see if they've expressed an opinion about how that syntax will interact with the JS syntax.
@mure mure added the enhancement New feature or request label Jun 30, 2022
@jattasNI
Copy link
Collaborator Author

TypeScript's documentation for member visibility states that both the private syntax and the # are supported (if you target ES2021 or less, it uses WeakMap rather than the native syntax for #). It doesn't take a position on using one or the other, besides their differences in behaviour (edit-time vs run-time privacy).

@jattasNI
Copy link
Collaborator Author

Some thoughts from today's meeting:

  • should allow the # in our conventions but not take a stand on using it vs private until NI devs and the community have time to form opinions about the new syntax
  • shouldn't use the # syntax in TS codebases that target ES2021 or earlier because the WeakMap approach is likely poor performing

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

No branches or pull requests

2 participants