svelte-select
svelte-select copied to clipboard
Property 'index' does not exist on type '{ selection: any; }'
VSCode is warning me that let:index
is not typed, but it works as it should.
v5.7.0
<Select
multiple
{loadOptions}
bind:value={selected}
bind:justValue
on:input={(e) => dispatch('select', e.detail)}
>
<div
slot="item"
let:item
>
{item.label}
</div>
<div slot="selection" let:selection let:index>
{selection.label} - {index}
</div>
<div slot="empty" >Nothing found...</div>
</Select>
I think this is a svelte bug/limitation. Index doesn't always exist on that slot, so it doesn't include it in the type. The easy fix would be to just set the index to 0 for non-multiple selects.
@rob-balfre Would you accept a PR that does this?