You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If we use any callback lets say for useTransition hook, type inference will fail if you use boolean as data. While investigating the root cause, I stumble upon this EventHandler. By reducing it to a single parameter function definition I could identify the issue with boolean type.
The real issue is that Item extends undefined that simply doesn't work with boolean type. Instead, as I expected both source code and who uses EventHandlers doesn't simply omit the item argument but provides a undefined-ish value, we could do:
That will still allow Item to be inferred properly. After locally testing it by applying that change directly on my node_modules/@react-spring/types/dist/react-spring_types.modern.d.ts, it worked. As I simplified the EventHandler the actual change would be:
Which react-spring target are you using?
@react-spring/web
@react-spring/three
@react-spring/native
@react-spring/konva
@react-spring/zdog
What version of react-spring are you using?
9.7.4
What's Wrong?
If we use any callback lets say for
useTransition
hook, type inference will fail if you useboolean
as data. While investigating the root cause, I stumble upon thisEventHandler
. By reducing it to a single parameter function definition I could identify the issue withboolean
type.To Reproduce
If you try to assign
EventHandler
to an arrow function to see the error happening, you'll notice the issue, as pointed in here, but also below:Expected Behaviour
The real issue is that
Item extends undefined
that simply doesn't work withboolean
type. Instead, as I expected both source code and who usesEventHandler
s doesn't simply omit theitem
argument but provides aundefined
-ish value, we could do:That will still allow
Item
to be inferred properly. After locally testing it by applying that change directly on mynode_modules/@react-spring/types/dist/react-spring_types.modern.d.ts
, it worked. As I simplified theEventHandler
the actual change would be:Source code
Link to repo
The text was updated successfully, but these errors were encountered: