You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expected behavior $userName1 works as expected. $userName2 and $userName3 are erroneous. I am not sure what behavior should be expected here, but what occurs is certainly not it. We could
throw an error (possibly at compile time).
Attempt to destructure the prop with the same name. That is, $userName3 should look for a prop named $userName3 and get undefined (matching what appears to happen to userName2). This is a no magic solution following standard js behavior.
Attempt to access the prop with the same name as the store, without the dollar sign. So $userName2 and $userName3 would get obj.userName2 and obj.userName3 respectively. This is a magic solution that makes sense combined with the inherit magic of stores.
Severity
Low. I think attempting to destructure in any way other than the way I did with $userName1 is asking for trouble. I have no intention of trying to de-structure into stores any other way, if I destructure into stores at all.
Additional context
Found due to question asked by OwnageJuice
The text was updated successfully, but these errors were encountered:
firefish5000
changed the title
Destructuring directly into a store has undefined bahaviour
Destructuring into a store without rename syntax results in undefined behavior
Nov 7, 2020
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Describe the bug
Destructuring into a svelte store directly, without typing the prop name in a rename syntax results in undefined behavior.
To Reproduce
https://svelte.dev/repl/1e4f6ca9cf9c4f60ab48f40c5cf73d2a?version=3.29.4
Expected behavior
$userName1
works as expected.$userName2
and$userName3
are erroneous. I am not sure what behavior should be expected here, but what occurs is certainly not it. We could$userName3
should look for a prop named$userName3
and get undefined (matching what appears to happen to userName2). This is a no magic solution following standard js behavior.$userName2
and$userName3
would getobj.userName2
andobj.userName3
respectively. This is a magic solution that makes sense combined with the inherit magic of stores.Severity
Low. I think attempting to destructure in any way other than the way I did with
$userName1
is asking for trouble. I have no intention of trying to de-structure into stores any other way, if I destructure into stores at all.Additional context
Found due to question asked by OwnageJuice
The text was updated successfully, but these errors were encountered: