Question about @const #15766
Unanswered
motherthestate
asked this question in
Q&A
Replies: 2 comments 1 reply
|
This does sound like a bug. Similar to e.g.: If you can create a reproduction in the Svelte playground, I would recommend opening an issue about this (in the Svelte repository, not SvelteKit). This does not sound SvelteKit-specific, but if it can only be reproduced via Kit, then it might be related to SSR & hydration. Make sure to update everything to the latest version. |
0 replies
|
@brunnerh Gonna open an issue, on further inspection, no pun intended. The issue seems to be $inspect. https://svelte.dev/playground/bda582387f424db190fa30d51c5334e0?version=latest |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I've encountered this issue a few times now and im not sure if this is expected behavior so I'm making a discussion instead of opening an issue for now.
When using @.const inside an #if the value seems to sometimes not respect the condition, or at least seems to be updated out of order with the check. In the snippet below it is possible to get an error like "Cannot read properties of undefined (reading 'items')" when ok becomes false or openThing becomes undefined. Even though the check should make this type safe and this would not happen in normal JS if clause.
All reactions