-
Notifications
You must be signed in to change notification settings - Fork 6
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
[TypeScript] GestureEvent
Callbacks Aren't Supported In Strict Mode
#28
Comments
What linter are you using? This should not produce any warnings or errors: import type { GestureEventData } from "contactjs";
const element = document.getElementById("targetElement") as HTMLElement;
element.addEventListener("panstart", (e: CustomEvent<GestureEventData>) => {
console.log(e);
}); Technically speaking, the following is preferred but the types are slightly still borked in v2.1.0: import type { GestureEvent } from "contactjs";
const element = document.getElementById("targetElement") as HTMLElement;
element.addEventListener("panstart", (e: GestureEvent) => {
console.log(e);
}); |
I'm using preact setup with |
I just released |
@orangecoloured I'd recommend trying the second solution using |
TS version is |
I managed to reproduce your issue, it requires Discussions for possible resolutions are here. |
GestureEvent
Callbacks Aren't Supported In Strict Mode
For the time being I recommend the following as a workaround: import type { GestureEvent } from "contactjs";
const element = document.getElementById("targetElement") as HTMLElement;
element.addEventListener("panstart", (e) => {
const event = e as GestureEvent;
}); |
Sorry I use issues for this kind of questions.
Do I understand correctly that I need to use
CustomEvent<GestureEventData>
for the handler functions?And if so, what do I do with the
addEventListener
call type errors? It expects to haveEvent
for the event parameter, but getsCustomEvent<GestureEventData>
. Is there a wrapping function that could avoid this type conflict or am I missing something?Should I use some workarounds to make TS linter happy?
The text was updated successfully, but these errors were encountered: