DEV Community

Discussion on: ECMAScript Decorators. The Ones That are Real

Collapse
 
what1s1ove profile image
Vladyslav Zubko • Edited

Hey @lexiebkm !

I thought decorators were only available in TS not JS. I have seen Angular rely on them to define modules and components; that's why it requires TS

To be honest, Angular uses a "third-party" compiler. If you're interested, you can read more about it πŸ˜‰

Now, with JS through newest ES provides decorators, I can expect to learn NestJs using JS.
Oh.. I am expecting Angular will support JS too.

Unfortunately, it's not quite that simple. In the latest version of Angular, there is support for native JavaScript decorators since TypeScript also supports them. However, NestJS is not in a rush to support these new decorators and currently works only with the old ones (you can reread the section about the history of decorators where I tried to explain everything).

I agree, for someone who is only observing this from the outside, it may seem quite puzzling. However, there are explanations for everything.

However, when will the specification of decorators become standard ?

I very much hope that in the next release or the one after that, we will see native decorators in the language standard. It is high time to put an end to this decade-long confusion, especially since recent TC39 meetings have been focusing on only minor changes.

Collapse
 
lexiebkm profile image
Alexander B.K.

Thanks for your reply and explanation.
I think, I can wait when decorators become standard. Your examples of using them here are impressive, especially with HOC.

Thread Thread
 
what1s1ove profile image
Vladyslav Zubko

Thank you @lexiebkm ! I really love β€œlive” examples. Everything is easier with them!