Deep introduction to class decorators in TypeScript
techsparx.com
techsparx.com
For what it’s worth, it seems like the proposal may move towards stage 3 soon - another round of review is going on here: https://github.com/tc39/proposal-decorators/issues/442
So, beware libraries or frameworks that rely on this toolset.
But yes, I think jest, a "JavaScript testing framework designed to ensure correctness of any JavaScript codebase" should support JavaScript features, even the ones you don't like the provenance of.
Some form of them might eventually be a JavaScript feature, but anything using them now is potentially incompatible with that future form.
class Example extends mixin(BaseClass) {}
as opposed to the decorator style: @mixin
class Example extends BaseClass {}
If you dislike decorators, what are your thoughts on this style of code?Can you use them poorly? Sure, but this applies to anything.
I.e. how is a decorator like this:
@dec
class Foo {...}
Different than this? let Foo = dec(
class Foo {...}
);
It seems the same to me (mostly). The above has a better syntax.Now that’s wrong. Decorators don’t work on functions, just methods.
Which is ironic if you think about it, because if you program with functions you already have the tools you need to compose things, no need to invent some syntax sugar like this. For some reason object oriented programmers don’t seem to think like that. They want a special name and special syntax for everything.
The fact that this became the most upvoted comment on hacker news signals me something sad about this sites moderation. In addition to the fact that other most upvoted comments(arguments) are lacking depth and good context:
1 - not standard so I won't use it(yet mitigating would be easy & basic and there is a major/popular implementation in typescript), 2- I don't like how it looks(decades long I'm an artist argument)
Good arguments & discussions usually require in-depth knowledge, given how fast programming communities grow, there will be people who make these shallow arguments and they will get upvoted(will have more people agreeing to them).
Sadly this means old communities like hacker news content and moderation will get spoiled by this behavior and standard committees will keep getting many noisy pushback & shallow criticisms as more people become programmers and will have tendency to share their newly formed opinions rather too quickly.
I like and ok with criticisms, however I hope and expect them to be in-depth, not disappointingly this shallow.