svelte-select icon indicating copy to clipboard operation
svelte-select copied to clipboard

Property 'index' does not exist on type '{ selection: any; }'

Open StrawHatHacker opened this issue 1 year ago • 1 comments

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>

StrawHatHacker avatar Nov 13 '23 13:11 StrawHatHacker

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?

knd775 avatar Apr 03 '24 16:04 knd775