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
v2 types #840
v2 types #840
Conversation
toValue: number, | ||
userConfig?: Omit<TimingConfig, 'toValue'>, | ||
callback?: (isCancelled: boolean) => void, | ||
): number; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this should return a number. Each animation actually returns an object. But maybe @kmagiera have better thoughts on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’m doing this to make the imperative compatible with:
- SharedValue
- react-native styles (ViewStyle, TextStyle, ImageStyle)
Thoughts @kmagiera?
After some local usage of these types (patch-package to enjoy the types), I saw that generics don’t work for I also saw I’ve forgot the |
Yeah, right now typescript annotations aren't getting removed from worklets before babel plugin processing them. |
@renanmav actually, Shared Value is not a class in the code, I would just use type/interface here. There is no way to Also, as I mentioned before, |
@renanmav Thank you so much for your effort. With now type annotations supported with worklets, things are getting interesting :) I'm also thinking about an eslint plugin to check the env variables used from worklets 😅 I'm trying your definition and added a definition for // reanimated2 functions
export function runOnUI<ReturnType>(fn: () => ReturnType): () => ReturnType;
export function runOnUI<P1, ReturnType>(fn: (p1: P1) => ReturnType): (p1: P1) => ReturnType;
export function runOnUI<P1, P2, ReturnType>(fn: (p1: P1, p2: P2) => ReturnType): (p1: P1, p2: P2) => ReturnType;
export function runOnUI<P1, P2, P3, ReturnType>(fn: (p1: P1, p2: P2, p3: P3) => ReturnType): (p1: P1, p2: P2, p3: P3) => ReturnType;
export function runOnUI<P1, P2, P3, P4, ReturnType>(fn: (p1: P1, p2: P2, p3: P3, p4: P4) => ReturnType): (p1: P1, p2: P2, p3: P3, p4: P4) => ReturnType;
export function runOnUI<P1, P2, P3, P4, P5, ReturnType>(fn: (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => ReturnType): (p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) => ReturnType;
export function runOnUI<A, ReturnType>(fn: (...args: A[]) => ReturnType): (...args: A[]) => ReturnType;
//...
export const runOnUI: typeof Animated.runOnUI |
@terrysahaidak how can we deal with assigning animations to shared values? Here We can do something like this:
Not sure how to define |
I’m not sure what |
runOnUI call a worklet function from the JS thread. You can pass it parameter. You can see an example of it at https://github.com/wcandillon/can-it-be-done-in-react-native/blob/master/reanimated-2/src/Worklets/Worklets.tsx#L53 |
So, can I add your |
Update react-native-reanimated.d.ts
@renanmav Great work! about the CI failure, could it be just a matter of merging the latest master into this branch? @terrysahaidak Does this work for you as well? |
…nimated into v2-types
react-native-reanimated.d.ts
Outdated
): number; | ||
export function withSpring( | ||
toValue: number, | ||
userConfig?: Omit<SpringConfig, 'toValue'>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SpringConfig is missing velocity: number
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 5fd666e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is withDecay already in the master.
type DecayConfig = {
deceleration?: number;
velocity: number;
clamp?: [number, number];
};
export function withDecay(
userConfig: DecayConfig,
callback: (isCancelled: boolean) => void
): number;
Thks for your review @terrysahaidak
@renanmav you rock! |
@renanmav velocity is not required AFAIK. |
@renanmav Could you fix the merge conflict? |
Is a proposal for the merge conflict: https://github.com/renanmav/react-native-reanimated/pull/3/files |
Fix merge conflict
The sequence helper has been added recently. Also, Loop has been renamed to repeat |
2. Add repeat function 3. Add sequence function 4. Add test for sequence function
@renanmav This pull request should fix this https://github.com/renanmav/react-native-reanimated/pull/4/files |
Change loop to repeat and add sequence function
Shall we merge this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think yes. I'm still not convinced about tests being in the root of the package and adding react-native-gesture-handler
as a peer dependency, but we can fix it in the follow-up PR after tests to the Reanimated 2 are set up.
🎉 |
Woah congrats everyone 🙌🏻 @renanmav you're our TypeScript hero 🦸🏻♂️ |
Do you guys have an eta on when these will become available in alpha release? |
you can use https://www.npmjs.com/package/patch-package in the meantime.
…On Mon, Aug 3, 2020 at 11:15 AM MinimogDev ***@***.***> wrote:
Do you guys have an eta on when these will become available in alpha
release?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#840 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AACKXVSZOFU3UR6BVYQ34CLR6Z523ANCNFSM4NOO3IIA>
.
|
Description
This PR includes the type definitions for react-native-reanimated v2. I created these types following the documentation and doing a quick check within the source code. Tested it against some changes I made on my reanimated-v2-playground. A better test would be to use these types on example app.
Suggestions
Increase DX for types, lint-staged isn’t configured to work for typescript files.