ni / javascript-styleguide

JavaScript and TypeScript Style Guide
MIT License
9 stars 9 forks source link

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

Open jattasNI opened 2 years ago

jattasNI commented 2 years ago

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.
jattasNI commented 2 years ago

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 commented 2 years ago

Some thoughts from today's meeting: