-
Notifications
You must be signed in to change notification settings - Fork 26.7k
Description
Which @angular/* package(s) are relevant/related to the feature request?
core
Description
I have searched through the issues and I haven't found any issue where this feature is asked. Feel free to close it if it's a duplicate.
I found this but it's not exactly what I'm proposing.
I wanted to create a new Angular project using the TC39 decorators proposal.
I wanted to ask if it's possible for Angular to support both type of projects (experimentalDecorators: true|false
). I don't use parameter decorators, the only decorators that I use are the class based decorators @Injectable
, @Component
, @Directive
and @Pipe
.
In my project I wanted to write some decorators like @debounce
or @throttle
and I wanted to write them based on the TC39 proposal as TypeScript and esbuild both have support for them.
I think it's possible to support projects with experimentalDecorators: true
and projects with experimentalDecorators: false
. See lit as an example:
https://github.com/lit/lit/blob/main/packages/reactive-element/src/decorators/property.ts#L198-L226
https://github.com/lit/lit/blob/main/packages/reactive-element/src/decorators/custom-element.ts#L46-L62
I'm aware that parameter decorators are not yet supported and they're part of another proposal that is not yet finalized. But for developers that use Angular without parameter decorators maybe it would be nice to be able to write standard decorators.
One nice thing about the TC39 proposal is that one can use the decorators in private class fields.
Proposed solution
I'm proposing doing something like what lit does. Although this implies that projects with experimentalDecorators: false
won't be able to use parameter decorators.
Alternatives considered
Writing my own class based decorators that replace the Angular ones will be the only alternative that I see.