-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Hi,
I'm trying to use useSprings with Typescript, and the setter seems to be defined incorrectly in the d.ts. This was equally a problem in v8 but my understanding is that you're not taking updates typing there ;)
The useSprings (plural) setting is currently defined like this for v9
export interface SpringUpdateFn<T extends object = {}> {
/** Update the props of a spring */
(props: SpringUpdate<T>): void
export type SpringUpdate<T extends object = {}> = Partial<T> &
SpringProps<{ to: T }> &
UnknownProps
But it seems to me like it should be this:
export type SpringsUpdateFn<Props extends object = {}> = (
i: number
) => Props & UseSpringProps<Props>
I tried to create a PR to help here, but I'm getting an error (below) after running thru the contributing script and hooking it into my project:
.../react-spring/packages/core/src/legacy.js
SyntaxError: .../react-spring/packages/core/src/legacy.js: Unexpected token (25:6)
23 | const element = is.fun(result) ? result(props) : result
24 | return element && element.type ? (
> 25 | <element.type {...element.props} key={key} ref={element.ref} />
| ^
26 | ) : (
27 | element
28 | )
If someone can either help me with the PR building or just make the update themselves, I'd be happy to test it for you. I'm confident on this since my old code that worked on v8 still works on v9, just the typing here is problematic in both versions. (If I'm using it wrong in both, please let me know!)
Thanks,
Barry