When starting out with building Aurelia custom elements (using typescript) I decided to declare members only used by the custom element as private, even if they are also used in the html template. This makes them hidden if someone decides to make a view-model.ref on the element and access the custom element class through code, but since “private” doesn’t really exist in javascript, the html template can still access them.
Now my IDE of choice, Visual Studio 2017, has gotten more clever with typescript classes and started doing this for these private members as they are only read in the html template;
So my instinct is to now remove private on these members so that the IDE wont confuse myself and my colleagues. But then it will exposed if someone interacts with the element through code as described above, which could cause unexpected usage of the custom element.
I used to mark them private as well. But then i changed all to public and decorated with @internal since it best describes the intention, at least for me. Also internal will make the typing disappear if you are building a library
Yes, its only for communication, which means consumer of the class will be signaled that its not available for use outside of the class. Theoretically, they are not private, making them as such could cause confusion down the road
So what I’ve been describing about my choice is to make things look like they way they actually are. With optional comment as a signal for reader of the class members. In stead of trying to make theoretically-public members private. The @internal comment servers 2 purposes: for app, it signals that the public member is a semi private member, shouldn’t be used directly outside of the class. For lib, it will be stripped from generated .d.ts, thus user of the lib will not see it, yielding similar effect to private.
Ok, got it. Thanks for your input. Using some comment like that seems like the way to go.
Considering that @internal then is some part of the spec of generation of *.d.ts files it shouldn’t be too far-fetched to suggest to IDEs that it should also affect intellisense.
(In my case I’m not building a lib, the custom elements are directly used within the same app/code base.)