3 ms·
I've never had any issues with enums, namespaces or private keywords (can't speak for decorators as I haven't used them yet). Although I do understand the reaso
by dmarchuk 5y ago
I've never had any issues with enums, namespaces or private keywords (can't speak for decorators as I haven't used them yet). Although I do understand the reasoning for using the '#somePrivateField' rather than 'private somePrivateField'.
But features like enums are part of the reason why we even have tools like TypeScript, because JavaScript lacks these features.
- wdb 5y agoI wish TypeScript somehow would use #-private fields underwater when compiling code. `#field` is pretty confusing; I keep thinking it's a comment and it looks ugly
- dmarchuk 5y agoAlthough I do understand the reasoning in the article, I completely agree with you. Switching between Python and TypeScript/JavaScript all the time, using ‘#’ to define private field feels weird and I personally prefer more explicit way of writing code. Plus AFAIK the ‘private someField’ is common in other languages (Java, Scala,…).
- paleite 5y agoCouldn’t agree more! Explain the differences in the following to a new developer: something - a regular variable $something - just another regular variable with a fancy char #something - now that’s a private variable !something - this is… uhm… a regular variable cast to… eh… boolean, then inverted… ~something - type cast blah blah bit flipping magic !!something - same as !something except inverted again, because using Boolean(something) is not 1337 //something - a comment Yeah… personally, I much prefer the more explicit ways to write code. it’s cryptic enough as it is, why make it harder for your peers