-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Describe the bug
I'm currently migrating another project to Svelte 5 and I have noticed that classes with reactivity are pretty hard to deal with. Reactive properties are not included in methods/functions like JSON.stringify, structuredClone. I understand that reactive properties generate getters and setters, but the docs don't mention the incompatibility and as far as I know there are no built-in functions to do stuff like this.
This is a pretty big pitfall in my opinion. You can't use classes the way you are used to, and you have to write your own helper functions for basic stuff like stringify. Arrays, maps, nested reactive classes and so on make things even more complicated.
I know that this how classes with getters and setters work in JS, but when you migrate, and you get the binding_property_non_reactive warning you simply make the property reactive, and now it's not included anymore.
Reproduction
Logs
No response
System Info
System:
OS: Linux 6.11 EndeavourOS
CPU: (4) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
Memory: 9.31 GB / 15.32 GB
Container: Yes
Shell: 5.9 - /usr/bin/zsh
Binaries:
Node: 23.1.0 - /usr/bin/node
npm: 10.9.0 - /usr/bin/npm
pnpm: 9.12.3 - ~/.local/share/pnpm/pnpm
Browsers:
Chromium: 130.0.6723.91Severity
annoyance