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
Fix parameter type of useTransform #843
Conversation
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 14b860c:
|
Instead of union of three different options:
You can just define only
|
@o-alexandrov
and similar test case already exists. motion/src/value/__tests__/use-transform.test.tsx Lines 39 to 50 in dc571a6
|
@kena0ki hello, thank you for the reply. I admit I typed the first message above from a phone not checking anything :D |
@o-alexandrov |
Yeap, let me please share a screen recording as well.
I don't have a permission to push to your branch, so I demonstrated via screenshots above and a video below. |
@o-alexandrov
If this case is ignorable, I agree your suggestion is better. |
Thank you for the clarification @kena0ki
There are two options of defining those types then, either: | MotionValue<string>[]
| MotionValue<number>[]
| MotionValue<string | number>[] or: (
| MotionValue<string>
| MotionValue<number>
| MotionValue<string | number>
)[] |
@@ -160,12 +160,19 @@ export function useTransform<I, O>( | |||
* @public | |||
*/ | |||
export function useTransform<I, O>( | |||
input: MotionValue<string | number>[], | |||
input: |
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.
you might consider assigning this typings to a type variable and reuse it in the next function below
input: MotionValue<I> | MotionValue<string | number>[], | ||
input: | ||
| MotionValue<I> | ||
| MotionValue<string>[] |
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.
here
Thank you for the suggestions. |
Fixes #840
I added
MotionValue<number>[]
andMotionValue<string>[]
to the type of the first parameter of the third useTransform function using union type.* Changes about FramerTreeLayoutContext are resulted from previous commit.