4 ms·
At runtime, TypeScript is JavaScript, so depending on your perspective either encapsulation is impossible (because you don't have types to defend you) or easy (
by evmar 7y ago
At runtime, TypeScript is JavaScript, so depending on your perspective either encapsulation is impossible (because you don't have types to defend you) or easy (because you use the patterns that JS has to defend encapsulation at runtime, without types).
- recursive 7y ago#private is coming soon, so that won't really be true any more. https://github.com/microsoft/TypeScript/pull/30829 https://github.com/microsoft/TypeScript/pull/30829 You'll have class members with accessibility in their declaration, and real run-time encapsulation.