svelte icon indicating copy to clipboard operation
svelte copied to clipboard

Using a generic type as an argument to a Snippet breaks types generation of a component

Open tommyminds opened this issue 7 months ago • 3 comments

Describe the bug

When I use a generic type as an argument to a snippet, svelte-package does not properly generate a Component.d.ts file for my component anymore.

While I understand the following test case is a bit weird, I do have several components where I use the type of one of the properties to determine the type that is passed to subsequent snippets.

Reproduction

<script lang="ts" generics="T">
	import type { Snippet } from 'svelte';

	let {
		data,
		someSnippet
	}: {
		data: T;
		someSnippet?: Snippet<[T]>;
	} = $props();
</script>

<div>{@render someSnippet?.(data)}</div>

Logs

No response

System Info

System:
    OS: macOS 14.5
    CPU: (8) arm64 Apple M1 Pro
    Memory: 72.55 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.1 - ~/.nvm/versions/node/v18.19.1/bin/node
    Yarn: 1.22.22 - ~/.nvm/versions/node/v18.19.1/bin/yarn
    npm: 10.2.4 - ~/.nvm/versions/node/v18.19.1/bin/npm
    pnpm: 9.3.0 - /opt/homebrew/bin/pnpm
    bun: 1.1.13 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 126.0.6478.127
    Safari: 17.5
  npmPackages:
    svelte: ^5.0.0-next.1 => 5.0.0-next.166

Severity

blocking an upgrade

tommyminds avatar Jun 27 '24 11:06 tommyminds