robinrodricks / vue3-touch-events

Simple touch events support for vue.js 3
MIT License
244 stars 31 forks source link

Property 'swipe' does not exist, v-touch is any #24

Open petarhristov94 opened 1 year ago

petarhristov94 commented 1 year ago

For the following code inside my <template>:

<div ref="container" class="content" v-touch:swipe="handleContentSwipe">
  ...
</div>

I get the warning

Property 'swipe' does not exist on type '{ $: ComponentInternalInstance; $data: { timelineRef: Ref<HTMLDivElement> | null; wrapperRef: Ref<HTMLDivElement> | null; ... 6 more ...; timelineEvents: { ...; }[]; }; ... 11 more ...; $watch<T extends string | ((...args: any) => any)>(source: T, cb: T extends (...args: any) => infer R ? (args_0: R, args_1: R) => a...'.ts(2339)

additionally the v-touch directive is of type any:
image

Here's how I've imported the package to my vue 3 typescript project, using yarn and vite. I also use Volar in VS Code. In main.ts:

/* Vue Touch Events */
import Vue3TouchEvents, {
  type Vue3TouchEventsOptions,
} from "vue3-touch-events";

...

app.use(Vue3TouchEvents, {
  disableClick: true,
} as Vue3TouchEventsOptions);
app.mount("#app");

Any ideas how to fix the typings?

kirbby commented 1 year ago

Additional info, it happens on all events (press, swipe,...) While using vue-tsc 1.2.0 it will compile (altough in VS Code it shows the error), when going to the latest vue-tsc 1.4.4 it doesn't compile and fails with the error described by @petarhristov94 .

kirbby commented 1 year ago

It got fixed in vue-tsc. This can be closed!