fix: allow await in if block consequent and alternate (#16890)

Closes #16885
pull/16910/head
Yuki Ishii 2 days ago committed by GitHub
parent 303750a124
commit 5d1ffcf413
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: allow await in if block consequent and alternate

@ -23,7 +23,11 @@ export function IfBlock(node, context) {
/** @type {Statement} */
let statement = b.if(test, consequent, alternate);
if (node.metadata.expression.has_await) {
if (
node.metadata.expression.has_await ||
node.consequent.metadata.has_await ||
node.alternate?.metadata.has_await
) {
statement = create_async_block(b.block([statement]));
}

@ -0,0 +1,10 @@
{#if false}
{@const one = await 1}
{one}
{:else if false}
{@const two = await 2}
{two}
{:else}
{@const three = await 3}
{three}
{/if}
Loading…
Cancel
Save