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

Warning: Properties of objects and arrays are not reactive unless in runes mode #13811

Closed
MrWaip opened this issue Oct 23, 2024 · 7 comments · Fixed by #14192
Closed

Warning: Properties of objects and arrays are not reactive unless in runes mode #13811

MrWaip opened this issue Oct 23, 2024 · 7 comments · Fixed by #14192

Comments

@MrWaip
Copy link

MrWaip commented Oct 23, 2024

Describe the bug

Hi, I just updated svelte to version 5, and I get this warning

Properties of objects and arrays are not reactive unless in runes mode. Changes to this property will not cause the reactive statement to update 

There is obviously some bug in the analyzer. I do not mutate the object, but read its property

image

Reproduction

https://svelte.dev/playground/d38ff4e52c9c4b1cb7b5314a662e479a?version=5.0.5

Logs

No response

System Info

Severity

annoyance

@MrWaip
Copy link
Author

MrWaip commented Oct 23, 2024

This is also reproduced with typescript enams

@brunnerh
Copy link
Member

There is obviously some bug in the analyzer. I do not mutate the object, but read its property

The warning is telling you that if Marker.A is changed elsewhere, this reactive statement will not trigger in legacy mode.
The warning is correct in principle, but if Marker.A is immutable, this is a false positive.

You can ignore the warning using

// svelte-ignore reactive_declaration_non_reactive_property

@MrWaip
Copy link
Author

MrWaip commented Oct 23, 2024

In my case Marker is immutable. It's enum.

I don't really like the idea of monkey patching everywhere with comments)

@brunnerh
Copy link
Member

The problem is probably that components are analyzed in isolation, possibly without type information from the outside; at least that used to be the case previously.

@paoloricciuti
Copy link
Member

The problem is probably that components are analyzed in isolation, possibly without type information from the outside; at least that used to be the case previously.

Yup this is correct

@MrWaip
Copy link
Author

MrWaip commented Oct 23, 2024

Tricky rule

dae added a commit to ankitects/anki that referenced this issue Oct 26, 2024
* Update to stable Svelte 5 release

This causes a bunch of warnings to be omitted:

ts/routes/graphs/RangeBox.svelte:52:18
Warn: Properties of objects and arrays are not reactive unless in runes mode. Changes to this property will not cause the reactive statement to update (svelte)
                break;
            case RevlogRange.All:
                $days = 0;

They are triggered on enum references, and it appears to be a bug.
May need to report it to Svelte?

* Deps update

* Silence spurious errors + fix a real one

sveltejs/svelte#13811
@benmccann
Copy link
Member

here's a Svelte 5 upgrade PR that has lots of ignores related to this warning if you want to see some examples: immich-app/immich#13738

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment