3 ms·
The article (and author’s referenced tweets) center on private field access failures with Proxy, but (and) the same problems arise if you override subclass memb
by eyelidlessness 4y ago
The article (and author’s referenced tweets) center on private field access failures with Proxy, but (and) the same problems arise if you override subclass members which defer to their super for private access. This is something that works perfectly fine with the `private` keyword semantics in TypeScript which predate runtime private class members. I agree that the actual runtime behavior is harmful, and I will only use it very carefully with very skeptical consideration of whether there’s any value in using it.
Fortunately symbols provide exactly the same runtime encapsulation semantics with none of the footguns. It’s a little bit more ceremony, but you can achieve everything a private class field would accomplish by using singleton symbols as long as you don’t export them or otherwise expose them to a consuming scope.