Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong value.interpolate() type #571

Closed
vipseixas opened this issue Feb 25, 2019 · 4 comments
Closed

Wrong value.interpolate() type #571

vipseixas opened this issue Feb 25, 2019 · 4 comments
Labels
area: typescript Typescript issues
Milestone

Comments

@vipseixas
Copy link

vipseixas commented Feb 25, 2019

I tried to convert the "GESTURES (PULL & RELEASE)" example to typescript and the types don't match with reallity.

const [{ xy }, set] = useSpring(() => ({ xy: [0, 0] })) returns xy: OpaqueInterpolation<number[]> so xy.interpolate() expects (number[]) => string but in fact it only works with (number, number) => string

I had to use as any to make it work...

const translate = (x: number, y: number) => `translate3d(${x}px, ${y}px, 0)`;
return <animated.div {...bind()} style={{ transform: xy.interpolate(translate as any) }} />
@drcmda
Copy link
Member

drcmda commented Feb 27, 2019

for now i think that's fine, @jacobrask is currently making super efforts to transform the lib to TS, then we won't have to rely on contrib types - but it's gonna take a while.

@jacobrask
Copy link
Contributor

I'm soon done with the interpolation + animated types and I will back port (copy paste) them to the current external type definitions first. Your case is supported by the new annotations, as AnimatedArrays will properly expand to function arguments.

Just need to do some more testing, all APIs will now return a new SpringValue type which can be assigned to properties of animated components, but I need to make sure nothing breaks for people who wrap with styled-components etc.

@aleclarson

This comment has been minimized.

@jacobrask

This comment has been minimized.

@aleclarson aleclarson mentioned this issue Apr 14, 2019
5 tasks
@aleclarson aleclarson added this to the v9.0.0 milestone Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: typescript Typescript issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants