Re:Deep introduction to class decorators in TypeScript
by xtracto on Tuesday February 15, 2022 @08:27PM
(#30355277)
Just today i was bitten by a bug in a framework called NestJS that makes heavy use of decorators: Certain decorator they define doesnt work with Jest test framework.
Re:Deep introduction to class decorators in TypeScript
by dhritzkiv on Tuesday February 15, 2022 @11:19PM
(#30356307)
I use NestJS with Jest just fine. Lots of decorators, too. What bug did you encounter?
Re:Deep introduction to class decorators in TypeScript
by davidmurdoch on Tuesday February 15, 2022 @10:17PM
(#30355977)
Sounds like you were bitten by Jest inadequacies, no?
Re:Deep introduction to class decorators in TypeScript
by frenchy on Tuesday February 15, 2022 @10:21PM
(#30355998)
Jest is inadequate because it doesn't support some non-standard experimental feature that was shoehorned into TypesScript to make it look more like C#?
Re:Deep introduction to class decorators in TypeScript
by davidmurdoch on Tuesday February 15, 2022 @10:32PM
(#30356052)
This is a JavaScript feature and confusing the two makes finding answers to Typescript questions much harder.
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.
Re:Deep introduction to class decorators in TypeScript
by magicalist on Tuesday February 15, 2022 @11:23PM
(#30356339)
But decorators aren't a JavaScript feature, that's the point of this comment thread.
Some form of them might eventually be a JavaScript feature, but anything using them now is potentially incompatible with that future form.
Re:Deep introduction to class decorators in TypeScript
by davidmurdoch on Wednesday February 16, 2022 @11:51AM
(#30362323)
Oh yeah, sorry, I shouldn't have worded it that way. the decorators are being transpiled at runtime to standard JS, so why shouldn't tooling like jest be able to work with that?
Re:Deep introduction to class decorators in TypeScript
by xtracto on Wednesday February 16, 2022 @01:14PM
(#30363493)
Because there is something wrong happening while the transpilation of the non-standard feature is happening.
Re:Deep introduction to class decorators in TypeScript
by hmillison on Tuesday February 15, 2022 @11:30PM
(#30356371)
It’s truly insane to me that we’re still waiting on decorators from TC39. I’ve been seeing warnings to not use them SINCE shortly after ES2015. Since you’ve been able to use them for 7 years via transpilers, I wouldn’t hold my breathe on TC39 finally ending their bike shedding anytime soon. Feels like if the feature is useful to you, you should use it. If something changes, it would be an easy thing to codemod.
Re:Deep introduction to class decorators in TypeScript
by FinalBriefing on Tuesday February 15, 2022 @11:25PM
(#30356351)
Yea, it makes me really worried about Angular's future updates given its heavy usage of decorators.
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.