On TypeScript access modifiers and @bindable

Say I have this extremely simple TypeScript component:

export class MyComponent {
@bindable ACCESS_MODIFIER myProperty;

Is there any kind of best practice about which access modifier (public / protected / private) to use if a property is bindable and is meant to be used only in:

  • the component itself,
  • potential inherited classes,
  • the relative HTML views via Aurelia’s HTML attributes?

So far I’ve been often using private/protected as - I assume - the TypeScript compiler just drops modifiers, but as Aurelia is meant to use these properties I guess they are not strictly private/protected.

1 Like

There is none that I have seen. But you can consider anything bindable should be public, otherwise outside of the custom element / component cannot see it to bind with it.

Change handler should also be public because it’s needed to be “seen” by Aurelia to invoke

When your view model gets more complex overtime, it will appears clearer what makes sense to be private I believe