Skip to content

Make private functions private #1537

Closed
Closed
@shmuelie

Description

@shmuelie

Currently private functions are put on the prototype of a function so they are not really private. I suggest adding them as normal functions in the scope of the class so that they are in fact only accessible to the class.

Example

module Example
{
    export class ExampleClass
    {
        method()
        {
            this.privateMethod();
        }
        private privateMethod()
        {
            console.log("private");
        }
    }
}

would create

var Example;
(function (Example) {
    var ExampleClass = (function () {
        function ExampleClass() {
        }
        function ExampleClass_privateMethod()
        {
            console.log("private");
        }
        ExampleClass.prototype.method = function () {
            privateMethod();
        };
        return ExampleClass;
    })();
    Example.ExampleClass = ExampleClass;
})(Example || (Example = {}));

Metadata

Metadata

Assignees

No one assigned

    Labels

    By DesignDeprecated - use "Working as Intended" or "Design Limitation" instead

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions