Aurelia events and Typescript access specifiers

Consider the attached, detached, bind and unbind events for example.

These are Aurelia generated events that the project I am working on has generally left unmarked i.e. public access. The justification is that it is Aurelia convention to do so.

But is it really? And if so why?

Correctly (I believe) the Aurelia framework manages to call these event handlers when marked private. I would have thought this is what should generally be the specified access, unless there is good reason to specifically make them public for ‘outside use’ or even protected for inherited use.

Any thoughts?

2 Likes

public and private will not matter as far as Aurelia is concerned since this is actually just for typechecking. The output is the same. This will be concern for you writing your application whether or not you want typechecking against the usage of these.

export class Test {
    public testMe() { }
    private testMeAgain(){}
}

=

 var Test = (function () {
        function Test() {
        }
        Test.prototype.testMe = function () { };
        Test.prototype.testMeAgain = function () { };
        return Test;
    }());
1 Like

To be even clearer, access modifiers are a TypeScript construct which gets completely dropped upon transpilation into JavaScript.
See also On TypeScript access modifiers and @bindable

1 Like

Class fields will be coming which typescript will support with the #varible syntax.


and

1 Like