sveltejs / language-tools

The Svelte Language Server, and official extensions which use it
MIT License
1.25k stars 201 forks source link

Type error: Expected 0 arguments, but got 1 on argument in children() #2511

Closed shinokada closed 1 month ago

shinokada commented 1 month ago

Describe the bug

Using VSCode with Svelte for VS Code and following the doc, I get "Expected 0 arguments, but got 1.".

<!-- provider -->
<script lang="ts">
  import type { Snippet } from "svelte";
    let { children }: { children: Snippet } = $props();
</script>

<button>
    {@render children("some value")}
</button>
image image

Reproduction

The following code with using VSCode.

<!-- provider -->
<script lang="ts">
  import type { Snippet } from "svelte";
    let { children }: { children: Snippet } = $props();
</script>

<button>
    {@render children("some value")}
</button>

Expected behaviour

It should not have any warning.

System Info

Which package is the issue about?

Svelte for VS Code extension

Additional Information, eg. Screenshots

No response

jasonlyu123 commented 1 month ago

This is expected. Snippet meant Snippet<[]> which takes no argument. What you want is Snippet<[string]> or Snippet<[name: string]>.

https://svelte-5-preview.vercel.app/docs/snippets#typing-snippets

shinokada commented 1 month ago

Thank you for a quick reply.