-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Suggestion: internal modifier #892
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
Comments
Edited the title to make this a suggestion for |
I was going to raise a suggestion about this, but i found this! +1 for the suggestion! |
I'm not sure if "internal" should be mixed with "protected" etc. But at the very least, it would be very useful to use "internal" instead of "export" for module level definitions so that they could be only accessed by members of the same module in other files. |
+1 for the |
+1 for |
Meanwhile "_" is your friend to ease API discovery |
Maybe... but not for linters and SoC: there are already accessor modifiers, so prefixing Thanks @basarat |
+1, I am working on large code base to port from c# and it would leak many methods to consuming code outside of my module.
it may also be possible to ignore this during compilation and consider internal as public, but in generating definition file skip them. |
I have been working in typescript for a few months now, creating many modules and classes. This is one of my most desired features. +1 |
Related, #3854. Really I think there is a basic problem with trying to be too "pure OO" with access modifiers. This is JavaScript! Any access modifier is ultimately going to be advisory since people can use the Modifiers |
@benliddicott Yes, we know... But as TypeScript programmer (not JavaScript), it would be great. It is known that it generates plain ECMAScript, and consumers will be able to hack it. But this is not the TypeScript purpose (obfuscate, protect etc.), but maintain readability and increase productivity. I think that that is not the point of view. |
+1 for |
+1 |
My take on
We would want to emit any I'm not suggesting mixing |
@rbuckton looks nice :) thank you! |
closing in favor of #5228 |
Currently the spec reads: Protected property members can be accessed only within their declaring class and classes derived from their declaring class, and a protected instance property member must be accessed through an instance of the enclosing class.
Relaxing the constraint, "member must be accessed through an instance of the enclosing class" to allow all classes derived from the declaring class as long as they are declared in the same module as the declaring class, would make it possible to have module internal access.
This is closer to how Java implements protected access, rather than C#. Are there plans to add an
internal
access modifier? If not, then this may be a way to alleviate the pain of encapsulating internal class state.The text was updated successfully, but these errors were encountered: