sortablejs-vue3
sortablejs-vue3 copied to clipboard
Support generic type parameters
This update enables type checking scoped slots, and by extension, lets developers get type completions while writing the #item slot.
There is a "breaking change" to consider here: to access the type of the component, we can no longer use InstanceType<typeof sortable>, because it doesn't work with generic components. We have to replace InstanceType with ComponentExposed as described in this issue: Cannot use InstanceType<typeof Comp
This requires adding 'vue-component-type-helpers' (from the official Vue Language Tools repository) as a dev dependency.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Comments | Updated (UTC) |
|---|---|---|---|---|
| sortablejs-vue3 | ✅ Ready (Inspect) | Visit Preview | 💬 Add feedback | Sep 20, 2024 11:55pm |
Here's a screenshot of the type-hint you get in vs-code while hovering over the item slot of HelloWorld.vue. It automatically infers this from the type of the items parameter.
@MaxLeiter I don't know if you saw this. It should be pretty quick to review if you're interested in taking a look.
Could this be improved by using defineSlots?
defineSlots<{
item: (props: { element: GItem }) => any;
}>();
BTW, I'm happy to update this PR with the latest improvements in Vue 3.5. But only if the maintainer(s) will actually merge this PR.
Sorry for missing this. Thanks!