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

Fix parameter type of useTransform #843

Merged
merged 3 commits into from Oct 29, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions api/framer-motion.api.md
Expand Up @@ -260,10 +260,10 @@ export interface FeatureProps extends MotionProps {
// @public (undocumented)
export type ForwardRefComponent<T, P> = ForwardRefExoticComponent<PropsWithoutRef<P> & RefAttributes<T>>;

// Warning: (ae-internal-missing-underscore) The name "FramerTreeContext" should be prefixed with an underscore because the declaration is marked as @internal
// Warning: (ae-internal-missing-underscore) The name "FramerTreeLayoutContext" should be prefixed with an underscore because the declaration is marked as @internal
//
// @internal (undocumented)
export const FramerTreeContext: import("react").Context<SyncLayoutBatcher | SharedLayoutSyncMethods>;
export const FramerTreeLayoutContext: import("react").Context<SyncLayoutBatcher | SharedLayoutSyncMethods>;

// @public (undocumented)
export type GestureHandlers = PanHandlers & TapHandlers & HoverHandlers;
Expand Down Expand Up @@ -911,7 +911,7 @@ export function useTransform<I, O>(input: MotionValue<I>, transformer: SingleTra
// Warning: (ae-forgotten-export) The symbol "MultiTransformer" needs to be exported by the entry point index.d.ts
//
// @public
export function useTransform<I, O>(input: MotionValue<string | number>[], transformer: MultiTransformer<I, O>): MotionValue<O>;
export function useTransform<I, O>(input: MotionValue<string>[] | MotionValue<number>[] | MotionValue<string | number>[], transformer: MultiTransformer<I, O>): MotionValue<O>;

// @public
export function useViewportScroll(): ScrollMotionValues;
Expand Down
11 changes: 9 additions & 2 deletions src/value/use-transform.ts
Expand Up @@ -160,12 +160,19 @@ export function useTransform<I, O>(
* @public
*/
export function useTransform<I, O>(
input: MotionValue<string | number>[],
input:

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

| MotionValue<string>[]
| MotionValue<number>[]
| MotionValue<string | number>[],
transformer: MultiTransformer<I, O>
): MotionValue<O>

export function useTransform<I, O>(
input: MotionValue<I> | MotionValue<string | number>[],
input:
| MotionValue<I>
| MotionValue<string>[]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here

| MotionValue<number>[]
| MotionValue<string | number>[],
inputRangeOrTransformer: InputRange | Transformer<I, O>,
outputRange?: O[],
options?: TransformOptions<O>
Expand Down