0

Related to similar question that has a useful answer using Typescript private fields: It has the drawback that those fields become public fields in plain Javascript and there is a loss in protecting instantiation.

With Typescript 2.8 ECMAScript private fields support I was wondering if one could come up with another solution.

G. Vallereau
  • 141
  • 3
  • 8
  • Javascript hasn't access modifier like java or typescript. You have to use function-style object modeling if you want some kind of protection. – Stoic Lion May 18 '20 at 08:42
  • TC 39 [proposal on class fields](https://github.com/tc39/proposal-class-fields/) (which is stage 3 at the moment) includes a syntax to make a class field private (using `#`) – G. Vallereau May 18 '20 at 09:03

0 Answers0