maciekgrzybek / svelte-inview

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

Update for breaking changes in svelte-check 3.0 #24

Closed Trombach closed 1 year ago

Trombach commented 1 year ago

Hi there,

I've been using svelte-inview in my own project and noticed that type checking with svelte-check in HTML templates did not work anymore since I updated to svelte-check 3. The VS Code extension is also affected since it's been using svelte-check 3 from version 106 onwards. It turns out that a few adjustments have to be made to get it working again as svelte-check has changed its interface to get typings.

I have also changed the interface name from HTMLProps<T> to HTMLAttributes<T> as shown in the link above. In my test svelte-check did not infer the correct type when using HTMLProps, but it works with HTMLAttributes.

Let me know if you have any questions and thanks for creating this package!

maciekgrzybek commented 1 year ago

Hey @Trombach thanks for the PR, I'll take a look today :)

maciekgrzybek commented 1 year ago

All done @Trombach , version 3.0.2 is on npm now :) Thanks for your help again :)

Trombach commented 1 year ago

Awesome! Thanks so much. Types are properly derived in my html templates again :)

maciekgrzybek commented 1 year ago

Hey @Trombach are you sure that the types are working correctly now? I specifically mean the handlers -> on:enter etc

Trombach commented 1 year ago

Hi @maciekgrzybek, it seems to be working for me. In this little test component

<script lang="ts">
  import { inview } from 'svelte-inview';
</script>

<div use:inview on:enter={(event) => console.log(event)} />

the type of event is correctly inferred as CustomEvent<ObserverEventDetails> in VSCode, which is what is declared in the DTS file.

Is there anything in particular that makes you think it's not working? :thinking: Happy to help if I can :)

maciekgrzybek commented 1 year ago

It's all good :) I just switched to Webstorm and it turns out it doesn't work really well with Svelte :)