2

When I am using private keyword in typescript, tsc generates javascript code with public members. So private members of class in typescript are public members in javascript. Please look at this

How to write code in typescript to receive private members in javascript?

Yauhen
  • 1,145
  • 12
  • 19

1 Answers1

3

In javascript you can create private members using revealing module pattern

var MyClass = function() {

    var privateMember = function () {}


    return {
        publicMember: function () {}
    }
}

If you use typescript class, it is not possible, because it's generate prototype, which does not have private methods.

Andzej Maciusovic
  • 4,306
  • 1
  • 29
  • 40