Open astj opened 2 years ago
Introduced between 9.5.2-9.5.3, probably due to this commit – https://github.com/pmndrs/react-spring/commit/2725fc328b4cec9b726e5e04e912dfaa9359750a
@joshuaellis
Thank you for response. So, is it safe to downcast this any
to expected structure manually as a workaround? (In other words, is it just a type-inference problem and actual js implementation is not changed?)
It'll just be a type-inference problem.
Out of curiosity, how come you're still using the Component
signatures of react-spring
as opposed to hooks?
Generally we use hooks, but according to commit logs in our repo we've changed few hooks to <Spring>
some months ago. I believe there was a reason, but unfortunately we can't remember it anymore 😢
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.5.5 (maybe 9.5.3+?)
What's Wrong?
When
<Spring>
component used with render props, TypeScript compiler infers render prop asany
, which makes compiler emit errors whennoImplicitAny
enabled.With attached CodeSandbox (just using
<Spring>
component taken from https://react-spring.dev/components/spring#and-this-is-how-you-create-a-chain ), react-spring 9.5.2 works fine and infersstyles
prop as{opacity: SpringValue<number>, color: SpringValue<string>}
. But 9.5.3+ infers it asany
.To Reproduce
Place some
<Spring>
components using render props in its children with TypeScript.Expected Behaviour
The render prop in children of
<Spring>
is inferred to some object reflecting the component'sfrom
andto
props' structure.Link to repo
https://codesandbox.io/s/clever-jennings-wo8jet?file=/src/App.tsx