-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Svelte5: Potential Ownership False Positive 'mutated a value owned...This is strongly discouraged...' #10649
Comments
There are two false positives here:
|
I am not sure what to make out of this. I think, I have the same problem and have a simpler example: @dummdidumm do you mean that this error message is a bug or that I should find another way of solving this setup? |
@kuechlerm yea I think he means it is a bug since he's agreeing that they're false positives. Curiously with your example if you move <script context="module">
+ let list = $state([]);
</script>
<script>
import { setContext } from 'svelte';
let { children } = $props();
- let list = $state([]);
setContext('list', list);
</script>
{@render children()} ... then the error message disappears. |
…a module, hinting at a mutation encapsulated in a .svelte.js file; part of #10649
@dummdidumm The problem comes back currently with HMR, when code is changed on a running page. |
Please open a new issue with a minimum reproducible |
Describe the bug
Hello : )
I believe the below generates a false positive in terms of state ownership and mutation. This occurs in svelte next.68 - it did Not occur in next.61 - When creating an external state 'creator' like this:
~ createMyState.svelte.ts
And using it like this with
setContext()
:~ +page.svelte (Parent):
~Child:
You get the following console error:
However, if the
createMyState()
function is written within the +page.svelte (Parent) directly - Not external - it works fine with no errors.Reproduction
https://github.com/Mali-2/state
Logs
System Info
Severity
blocking an upgrade
The text was updated successfully, but these errors were encountered: