maciekgrzybek / svelte-inview

A Svelte action that monitors an element enters or leaves the viewport.🔥
MIT License
749 stars 23 forks source link

Binding element 'detail' implicitly has an 'any' type.ts(7031) #19

Closed Eulenmensch closed 2 years ago

Eulenmensch commented 2 years ago

Hey, I'm trying to use the provided animation example but I'm getting multiple errors. The detail element throws the error in the title and on:change is throwing the following error:

Type '({ detail }: { detail: any; }) => void' is not assignable to type 'FormEventHandler<HTMLDivElement>'.
Types of parameters '__0' and 'event' are incompatible.
Property 'detail' is missing in type 'Event & { currentTarget: EventTarget & HTMLDivElement; }' but required in type '{ detail: any; }'.
ts(2322)

finally, the class:animate{inView} just gives me an error that inView is not defined.

Sorry if this has an obvious solution, I couldn't find anything online and am still a little too new to programming to fully understand the error messages.

Thanks!

maciekgrzybek commented 2 years ago

Hey @Eulenmensch , can you provide a reproduction of your issue? It's hard to help without more context :)

Eulenmensch commented 2 years ago

Hi, I created a repro here. Thank you so much for getting back to me!

maciekgrzybek commented 2 years ago

I can't push the branch to your repo, so here's a screenshot :)

Screenshot 2022-06-13 at 21 58 58

First of all, you need to pass the correct type to the handleChange function, as it doesn't know what type it's using by itself. Also, you need to pass isInView instead of inview - that's a mistake in my readme :)

Thanks for pointing these out, I'll update the docs :)

maciekgrzybek commented 2 years ago

I've updated the redme file, so it might be easier now :) Hope it helps, let me know if you need any more assistance :)