-
-
Notifications
You must be signed in to change notification settings - Fork 223
Description
Describe the bug
I have a List.svelte component with generics="T" on the script tag. There is a data prop of type T[], and there is a row snippet prop that is typed as a function (item: T) => void.
When I declare the row snippet inside the component, I get an error at the start of my file that says Cannot move a selection inside itself. This error goes away if I move the snippet out of the component and pass it in as a prop.
The code still works fine, so I think it's just a problem with the Svelte language server or extension.
Reproduction
REPL (Error won't show up in the REPL, you may need to copy it over to VS Code)
Expected behaviour
There shouldn't be an error when declaring the snippet inside the component.
Also, I'm not sure if this would require extra work or if it would work once the error I mentioned gets fixed, but it would be really nice if the snippet you declare inside the component automatically inferred its parameter types based on the $prop types in the component. In other words, if I have my generic component, and I pass an array of numbers to the data prop, the row snippet's item parameter should automatically be inferred as a number (you can hover over the parameter and see that it's a number, and you should get intellisense/type checking for the number type inside the snippet block. What I don't want to have to do is specify the type inside the snippet block like this:
<List data={[1, 2, 3]}>
{#snippet row(item: number /* hopefully not necessary */)}
{item}
{/snippet}
</List>System Info
- OS: MacOs
- IDE: VS Code
Which package is the issue about?
svelte-language-server
Additional Information, eg. Screenshots
