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

Improve typescript support on slots #144

Open
SimonSimCity opened this issue Apr 28, 2022 · 1 comment
Open

Improve typescript support on slots #144

SimonSimCity opened this issue Apr 28, 2022 · 1 comment

Comments

@SimonSimCity
Copy link

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...

@moreant
Copy link

moreant commented Oct 13, 2022

@greenhat616
References https://stackoverflow.com/a/72916031/13621750

you can custom slot type like this
<template #item="{ element } : { element: CustomType }">

image

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