Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
StrawHatHacker opened this issue Nov 13, 2023 · 1 comment
Open

Comments

@StrawHatHacker
Copy link

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>
@knd775
Copy link

knd775 commented Apr 3, 2024

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants