robinrodricks / vue3-touch-events

Simple touch events support for vue.js 3
MIT License
216 stars 27 forks source link

Types incompatible with Vue 3.4.0+ #39

Closed kirbby closed 2 months ago

kirbby commented 4 months ago

With Vue 3.4.0 and higher there is a type issue for the plugin in the main.ts. Argument of type '[]' is not assignable to parameter of type 'never'.ts(2345) at app.use(Vue3TouchEvents);

I just tried to find a fix for a while, but I'm neither a TS wizard nor do I have any experience with creating Vue plugins, so help is appreciated.

tjbp commented 4 months ago

Until the types are fixed you can temporarily sort this by passing a type parameter: app.use<[]>(Vue3TouchEvents);

kirbby commented 4 months ago

Thanks, works like a charm!

stefan-hoelzl commented 2 months ago

When you want to set some options and also need typing support, you can also use the following:

import Vue3TouchEvents, {
  type Vue3TouchEventsOptions,
} from "vue3-touch-events";

app.use<Vue3TouchEventsOptions>(Vue3TouchEvents, {
  disableClick: true,
  touchHoldTolerance: 500,
})
robinrodricks commented 2 months ago

@stefan-hoelzl is this correct? https://github.com/robinrodricks/vue3-touch-events?tab=readme-ov-file#typescript-vue-34

stefan-hoelzl commented 2 months ago

@stefan-hoelzl is this correct? https://github.com/robinrodricks/vue3-touch-events?tab=readme-ov-file#typescript-vue-34

yes, this is how it is working for me! Thanks!

kirbby commented 2 months ago

This works, thanks! I wanna emphasize though, that you need to specify an options object, even if you are not passing any options to it, otherwise you still get a Typescript error. Not working: app.use<Vue3TouchEventsOptions>(Vue3TouchEvents) Working: app.use<Vue3TouchEventsOptions>(Vue3TouchEvents, {})

Maybe worth noting in the read.me @robinrodricks

Other than that this is resolved and I will close.