2 ms·
TypeScript's "private" is only for type checks. It is simply removed. You may also want to read what I wrote a few days ago already: https://news.ycombinator.c
by nosianu 3y ago
TypeScript's "private" is only for type checks. It is simply removed.
You may also want to read what I wrote a few days ago already: https://news.ycombinator.com/item?id=35653653 https://news.ycombinator.com/item?id=35653653
TypeScript now supports both the ECMAScript #private - it has no choice in the matter, since it's in the language now - and their own development-time "private". It sounds messy but that's the fault of those who wanted it in the language, as runtime checks.
I agree with the other comment, closures are far more powerful and flexible. I understand that this OOP stuff in JS was probably a nod to the many programmers in many companies already used to it, to make JS more palatable for them. It's easy to demand millions of people worldwide to adapt, but in business reality it does not work that way. So I grudgingly accept those new(er) things in JS as a business decision and necessity, for the huge crowd of people doing programming mostly just for the money, who had to write more and more code for the web that used to be run as installable software on Windows.