Skip to content
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

Decorators do not work with useDefineForClassFields = true #191

Open
sherlock1982 opened this issue Jan 27, 2025 · 0 comments
Open

Decorators do not work with useDefineForClassFields = true #191

sherlock1982 opened this issue Jan 27, 2025 · 0 comments

Comments

@sherlock1982
Copy link
Contributor

sherlock1982 commented Jan 27, 2025

Versions (please complete the following information):

  • NgxWebstorage: 19.0.1
  • Angular: 19.1.3

Describe the bug
Current Angular CLI on create sets target = es2022. This implies useDefineForClassFields = true.
Decorators like @LocalStorage are not working in this scenario

To Reproduce
Steps to reproduce the behavior:

  1. Create a new Angular app.
  2. Try to use @LocalStorage decorator
  3. It will always read undefined

Expected behavior
Read the value from local storage

Additional context
You can fix it by setting useDefineForClassFields = false. A good explanation of this feature (and why it should be set to true) is here.
I didn't really check in deep yet but I believe it has to do something with #esbuild/2220

I see that Angular now migrates to signals. See for example here. I think they're planning to get rid of decorators at least for class fields.

Maybe ngx-webstorage can also suggest something like this? You can even provide ChangeDetectorRef and support push also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant