sghall / react-move

React Move | Beautiful, data-driven animations for React
https://react-move-docs.netlify.app
MIT License
6.58k stars 168 forks source link

NodeGroup Add generic type from incoming data #69

Open FranzFlueckiger opened 3 years ago

FranzFlueckiger commented 3 years ago

This PR allows typescript users to directly have the type of the incoming data array inferred in all the following functions: keyAccessor, start, enter, update and leave. If this PR is accepted, nothing will change from the user's perspective except that they will enjoy code completion where they might expect it to be.

sghall commented 3 years ago

Good point 👍 Keep thinking I'm just going to re-write this in TS. I think you need to make it optional, right? So not all TS users need to provide a type?

Like...

type SomeType<T = void> = OtherType<T>;

https://garbagevalue.com/blog/optional-generic-typescript

FranzFlueckiger commented 3 years ago

Hi Steve, sorry for the late response. You're right that the generic should be optional so that this change is non-breaking for the users.