Add update? and destroy? to AnimationController interface
This fixed issue #82. However, I'm unsure if this could have side effects for other frameworks. Seeing as how they're optional type properties that Svelte just expects I figured it'd be safe to add them.
The latest updates on your projects. Learn more about Vercel for Git ↗︎
| Name | Status | Preview | Updated |
|---|---|---|---|
| auto-animate | ✅ Ready (Inspect) | Visit Preview | Sep 19, 2022 at 3:19PM (UTC) |
Not sure what all the implications are of adding this to other frameworks are either. Does it cause problems on the svelte side of things to not have these there? Type errors? Runtime?
It causes type errors (below). Code still compiles and it's fine. It's just because of how actions are defined in Svelte. You can see the docs for them here.
Argument of type 'AnimationController' is not assignable to parameter of type '__sveltets_2_SvelteActionReturnType'.
From the docs you can see that a Svelte action is defined like this
action = (node: HTMLElement, parameters: any) => {
update?: (parameters: any) => void,
destroy?: () => void
}
There's an optional destroy and update callback. Since the AnimationController interface doesn't have those defined it throws an error. It's not actually an issue since they're optional anyways. But, by adding them to the AnimationController interface it gets rid of the error on the Svelte/SvelteKit side.
This PR shouldn't hurt any other framework or cause any side effects. It just gets rid of annoying TS warning that us Svelte/SvelteKit engineers have to look at while using this library.

Seems odd since they are both optional not having them defined would cause a TS error in this case.