-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
Using this
alias breaks reactivity
#11480
Comments
Btw this is only true for private fields REPL. This is because when a private field is accessed with while with public fields the set still goes through the setter which actually does a |
Basically here we should check if node.object.type is svelte/packages/svelte/src/compiler/phases/3-transform/client/visitors/global.js Lines 16 to 34 in 34079a0
|
Is This the same as #11476 ? I think the easiest solution is to have a private getter/setter pair for each private state/derived backed by another private field. Bonus points for only doing that when we need to (i.e. when we detect this is assigned/passed to something) |
Yeah I think is the same. Since the problem is only there with private fields because public gets rewritten to private+get&set even if you return this you'll have no way to access them outside. I like your idea...we should explore every method of the class to be sure this is not assigned to a class property right? |
I would add metadata.needs_private_getters to the class node and set that to true in the analysis phase when detecting a this expression that is not the first part of a member expression. Then in the code gen phase create those private getters/setters if that field is true |
Great I'll try to give it a shot tomorrow if I have time. |
Describe the bug
When using an alias for
this
in a Class with runes, setting a state using the alias breaks the signal.Reproduction
REPL
Try to undo something on the 2nd example
Logs
No response
System Info
System: OS: macOS 13.4 CPU: (8) arm64 Apple M2 Memory: 86.95 MB / 24.00 GB Shell: 5.9 - /bin/zsh Binaries: Node: 21.6.2 - /usr/local/bin/node npm: 10.2.4 - /usr/local/bin/npm pnpm: 8.15.4 - /usr/local/bin/pnpm bun: 1.0.29 - ~/.bun/bin/bun Browsers: Safari: 16.5
Severity
annoyance
The text was updated successfully, but these errors were encountered: