3 ms·
Note that the decorators standard has changed substantially, and the experimental decorators implementation in Typescript now varies greatly from the existing p
by jitl 5y ago
Note that the decorators standard has changed substantially, and the experimental decorators implementation in Typescript now varies greatly from the existing proposals. The current feature has not been updated in years. I would not use this feature in my code, especially for critical facilities, or build a framework around it.
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 https://github.com/tc39/proposal-decorators/issues/442
So, beware libraries or frameworks that rely on this toolset.
- xtracto 5y agoJust 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.
- dhritzkiv 5y agoI use NestJS with Jest just fine. Lots of decorators, too. What bug did you encounter?
- davidmurdoch 5y agoSounds like you were bitten by Jest inadequacies, no?
- frenchy 5y agoJest is inadequate because it doesn't support some non-standard experimental feature that was shoehorned into TypesScript to make it look more like C#?
- davidmurdoch 5y agoThis 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.
- magicalist 5y agoBut 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.
- davidmurdoch 5y agoOh 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?
- xtracto 5y agoBecause there is something wrong happening while the transpilation of the non-standard feature is happening.
- FinalBriefing 5y agoYea, it makes me really worried about Angular's future updates given its heavy usage of decorators.
- hmillison 5y agoIt’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.