New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Class decorator stopped working on angular@15 #48276
Comments
Could you provide a working exemple ? I'm also getting |
Here is a working example:
|
It works on v15 in here |
Angular doesn't support custom decorators on its component classes or other decorated members. Depending on what the decorator does, it may or may not function correctly. We don't support them because there's a big conceptual mismatch - the Angular compiler is trying to statically transform classes according to their Angular annotations, but custom decorators are attempting to arbitrarily change the shape of that class at runtime. |
@alxhub Do you have some documentation or something that indicates that we cannot use custom decorators in Angular and why? We are meeting the same situation here with a decorator UntilDestroy() that makes the |
After some research, this is related to a modification of the way properties are set as you can see in the Typescript documentation. This new way is applied when your target is es2022. Angular cli is aware of this as you can this in this code , it will set the correct value The solution then is to set the target to es2021 then Angular Cli will hook the configurations and set es2022 and useDefineForClassFields to false There is only one thing that we still don't understand is that if you set these values yourself to avoid the warning of Angular Cli, then it doesn't work. It seems typescript will read directly the file and just ignore useDefineForClassFields Related tickets: |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Having class decorator:
And in component:
The text was updated successfully, but these errors were encountered: