We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I noticed that assigning states with asynchronous expressions in variable destruction doesn't quite work.
Code:
<script> let name = $state("tom"); let email = $state("tom@mail.com"); let number = $state(555); const fetch_name = () => { return new Promise((resolve) => { setTimeout(() => { resolve("jerry") }, 100) }) } const fetch_email = () => { return new Promise((resolve) => { setTimeout(() => { resolve("jerry@mail.com") }, 100) }) } const fetch_number = () => { return new Promise((resolve) => { setTimeout(() => { resolve(777) }, 100) }) } const update = async () => { // Code breaks here ({ name = await fetch_name(), email = await fetch_email(), number = await fetch_number() } = {}); } </script> <p>Name: {name}</p> <p>Email: {email}</p> <p>Number: {number}</p> <button on:click={update}>Update me</button>
Error compiling component
Cannot use keyword 'await' outside an async function (19:53)
Possibly related: #9686
Here is the reproduction on the Svelte 5 preview: https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACrVTPU_DMBD9K5bF4EoVLUNVKaQRDKwVA0wEodS9CkNsR_alVRX5v2M7TZPQAZZO9r13H-_O54buRAmWJm8NVYUEmtDHqqJTiscqGHYPJYK3ra4ND0hquREVZrnKsQQkIYqsyI3FAoHlFLXM6eS-o0EWovzFPwTslo8dVS03YHrPxWIRSU9zrSySHSD__DiVYxOyykgT2BwNYG0UUXAgz0ZLYYExA1aXexi65WgBX4QEXSNjYyYkiQFe4RcYc_TSOs5Nyd18fjJdPN2lsK7RqysbTu8PiXgxvW7I11O5XC7_Pbm62vqn9nIKe1R8LIo13WoVh0IMn59Npue1GnIRC-S5y1FkBH0J54nGtYvn1aSzfqFVWmVrXyEhTSjk0lmVRfAppPZoLNHD65gzeMdLR2xqRK2IVgkvBf9eNW2fLntt-5WQzlqfzP8sqbdiJ2BLEzQ1uHf3A_Rrp36UAwAA
No response
REPL
annoyance
The text was updated successfully, but these errors were encountered:
1ff9c0f
fix: support destructurings containing await (#9962)
43f204a
Adds a traversion mechanism to found out if destructured expressions contain await Fixes #9686 Fixes #9312 Fixes #9982
No branches or pull requests
Describe the bug
I noticed that assigning states with asynchronous expressions in variable destruction doesn't quite work.
Code:
Error compiling component
Possibly related: #9686
Reproduction
Here is the reproduction on the Svelte 5 preview: https://svelte-5-preview.vercel.app/#H4sIAAAAAAAACrVTPU_DMBD9K5bF4EoVLUNVKaQRDKwVA0wEodS9CkNsR_alVRX5v2M7TZPQAZZO9r13H-_O54buRAmWJm8NVYUEmtDHqqJTiscqGHYPJYK3ra4ND0hquREVZrnKsQQkIYqsyI3FAoHlFLXM6eS-o0EWovzFPwTslo8dVS03YHrPxWIRSU9zrSySHSD__DiVYxOyykgT2BwNYG0UUXAgz0ZLYYExA1aXexi65WgBX4QEXSNjYyYkiQFe4RcYc_TSOs5Nyd18fjJdPN2lsK7RqysbTu8PiXgxvW7I11O5XC7_Pbm62vqn9nIKe1R8LIo13WoVh0IMn59Npue1GnIRC-S5y1FkBH0J54nGtYvn1aSzfqFVWmVrXyEhTSjk0lmVRfAppPZoLNHD65gzeMdLR2xqRK2IVgkvBf9eNW2fLntt-5WQzlqfzP8sqbdiJ2BLEzQ1uHf3A_Rrp36UAwAA
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: