Skip to content

Add support for Svelte 5 generics #583

Closed
@marekdedic

Description

@marekdedic

Description

Hi,
generics are now officially part of Svelte 5. However, it seems to me that this parsers doesn't support them:

<script generics="KeyType extends number | string, ValueType" lang="ts">
  import type { Snippet } from "svelte";

  interface Props {
    children?: Snippet<[KeyType, ValueType]>;
    options: Array<[KeyType, ValueType]>;
    selected: Array<KeyType>;
  }

  let { children, options, selected = $bindable() }: Props = $props();

  selected;
</script>

{#each options as [id, value] (id)}
  <label>
    <input type="checkbox" value={id} bind:group={selected} />
    <span></span>
    {@render children?.(id, value)}
  </label>
{/each}

Gives 'ValueType' is not defined and similar

I tried to create a repro, but the playground is stuck at "Starting WebContainer"...

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions