Skip to content
New issue

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

{@const} inside {#key} block #8404

Closed
longnguyen2004 opened this issue Mar 21, 2023 · 5 comments
Closed

{@const} inside {#key} block #8404

longnguyen2004 opened this issue Mar 21, 2023 · 5 comments

Comments

@longnguyen2004
Copy link

Describe the problem

Since the current {#key} block operates like a 1-element {#each} block, it should make sense to allow using {@const} inside of {#key} as well.

Describe the proposed solution

Allow the usage of {@const} inside {#key}

Alternatives considered

Use a dummy {#if true} block

{#key ...}
    {#if true}
        {@const ...}
    {/if}
{/key}

Importance

nice to have

@longnguyen2004 longnguyen2004 changed the title {@const} inside {#key} block {@const} inside {#key} block Mar 21, 2023
@nevis2us
Copy link

nevis2us commented May 30, 2024

I second the move. Example use case:

{#key active}
{@const item = items[active]}
...
{/key}

@dummdidumm
Copy link
Member

This is allowed in Svelte 5

@longnguyen2004
Copy link
Author

Doesn't seem like it is allowed in Svelte 5, I'm still getting the same error

@paoloricciuti
Copy link
Member

Closed by #15377

@paoloricciuti
Copy link
Member

Closed by #15377

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants