Being able to omit the variable name when doing {#await promise then value} {/await}
#6476
Labels
{#await promise then value} {/await}
#6476
Describe the problem
Suppose you have a promise that doesn't return anything (i.e.
Promise<void>
in TypeScript terms). If you want to use Svelte's await syntax for such a promise, you can do so with separate{#await}
{:then}
blocks, and you're perfectly allowed to omit the variable name in the{:then}
block, like so:Svelte also provides an alternative syntax for when you don't want to show anything until the promise is resolved. It looks like this:
Explained in the official tutorial here.
Unlike what I expected, you cannot use the above syntax with a void promise, in other words you can't omit the variable name, so you can't do:
You'd get the following error:
Describe the proposed solution
I think the aforementioned syntax should be supported. You should be able to omit the variable name after
then
when you don't have a separate{#await}
block, just like you can do so when you do have a separate{#await}
block.Alternatives considered
You'd have to do the following, and have an empty
{#await}
block:which isn't nice.
Importance
would make my life easier
The text was updated successfully, but these errors were encountered: