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

Prefer real private fields over public/private #644

Open
jimmywarting opened this issue Jan 8, 2022 · 1 comment
Open

Prefer real private fields over public/private #644

jimmywarting opened this issue Jan 8, 2022 · 1 comment

Comments

@jimmywarting
Copy link
Contributor

jimmywarting commented Jan 8, 2022

Javascript has private class fields now... and compilers are able to downgrade it to using WeakMap if necessary.

I think public/private should be discouraged over the native approach. typescripts private keyword is only soft private and don't really protect anything. another thing is that compilers can mangle those hard private # names into 1-2 letter words when minifying

another thing could be to discourage class fields that starts with _ and warn/suggest to use # instead (for both js and ts)

...anything that have the keyword public is just bloated annotation, it's really just more simpler than that, everything that isn't private is public, why be so explicit?

@sindresorhus sindresorhus changed the title prefer real private fields over public/private Prefer real private fields over public/private Jan 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants