vue.draggable.next
vue.draggable.next copied to clipboard
Improve typescript support on slots
This repo has already some typescript definitions, but one I'm particularly missing is the typing of variables passed to a slot.
<draggable v-model="myArray" item-key="id">
<template #item="{element}">
<!-- "element" in here is of type "any", even though myArray has defined type in my case -->
<div>{{element.name}}</div>
</template>
</draggable>
Having types is really important for us as it prevents a lot of bugs.
Avoiding using properties passed in as parameters on the slot would work around this issue already - keeping it as it was on the previous implementation, where I had to use v-for inside the slot...
@greenhat616 References https://stackoverflow.com/a/72916031/13621750
you can custom slot type like this
<template #item="{ element } : { element: CustomType }">
