v1ack / svelte-virtual-scroll-list

Virtualized scrolling for big lists
https://v1ack.github.io/svelte-virtual-scroll-list/
MIT License
114 stars 18 forks source link

Update slot property name to avoid incorrect type #2

Closed www-chique closed 2 years ago

www-chique commented 3 years ago

Thank you Hey @v1ack , big fan of your package. It works much better than any other alternative. I am in love with the "pageMode", it works amazing and so practical. This repo deserves more github stars. Very developer friendly, very customizable and easy to use. Thanks for your work.


The original problem The let:data on the default slot is showing the wrong type as "any[]" (Array), instead of "any". image

And it's coming from here (VirtualScroll.d.ts) image


Explanation of the changes Simply renamed the "data" variable in the "each" loop to "dataItem" to avoid producing incorrect typescript definition on the default slot's property "data". As "data" is declared also at the top as the main component's property, with a type of Array, the slot's "data" property was also producing the same type as Array, where it should just be "any" as it's a single data item. As a work-around, I renamed the local loop variable to "dataItem" so Sveld treats it as a different variable from the "data" at the top, and produces the correct type definition.

It is a bug from Sveld, but for now this workaround works.

mellson commented 2 years ago

Any thoughts on this PR @v1ack ?

joaquimgamero commented 2 years ago

This would be very convenient, errors in the IDE are annoying!

legnaleurc commented 2 years ago

@v1ack would be great to have this patch merged.