Closed ACAlexChen closed 3 days ago
Property privacy in typescript is enforced only in typechecking, it has no runtime effect. If you want truly private properties, you probably want this. Those are enforced both when typechecking and on execution
See right hand side of screenshot of JavaScript output.
As mentioned by Nathan, what you want to use is JS private properties (see class B
above using #
): https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes/Private_properties
Version: Deno 2.1.1
Property 'a' should be only accessible within class 'A' But when I run this code with Deno, still can be accessible from outside