maciekgrzybek / svelte-inview

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

TypeScript error in 4.0.0 #40

Closed khromov closed 1 year ago

khromov commented 1 year ago

Hi, since the event name changed from on:change to on:inview_change, TypeScript doesn't seem to recognize it any more and displays an error:

Argument of type '{ class: string; "on:inview_change": ({ detail }: any) => void; }' is not assignable to parameter of type 'Omit<Omit<HTMLAttributes<HTMLDivElement>, "data-sveltekit-keepfocus" | "data-sveltekit-noscroll" | "data-sveltekit-preload-code" | "data-sveltekit-preload-data" | ... 49 more ... | "aria-valuetext"> & EventsWithColon<...>, keyof HTMLAttributes<...>> & HTMLAttributes<...>'.
  Object literal may only specify known properties, and '"on:inview_change"' does not exist in type 'Omit<Omit<HTMLAttributes<HTMLDivElement>, "data-sveltekit-keepfocus" | "data-sveltekit-noscroll" | "data-sveltekit-preload-code" | "data-sveltekit-preload-data" | ... 49 more ... | "aria-valuetext"> & EventsWithColon<...>, keyof HTMLAttributes<...>> & HTMLAttributes<...>'.ts(2345)
No quick fixes available

Is there some way to work around this? I'm using TypeScript 5.0.

khromov commented 1 year ago

Was a bit quick to jump the gun, restarting the Svelte language server in VS Code solved my problem. Thanks for a great package!