Skip to content

Commit 032c60b

Browse files
committed
fix: infer types from from function in useTransition
resolves pmndrs#1483
1 parent ad1ea2d commit 032c60b

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/core/src/types/props.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ export type PickAnimated<Props extends object, Fwd = true> = unknown &
352352
: [object] extends [Props]
353353
? Lookup
354354
: ObjectFromUnion<
355-
Props extends { from: infer From } // extract prop from the `from` prop if it exists
355+
Props extends { from: infer From extends object ? object : () => any } // extract prop from the `from` prop if it exists
356356
? ObjectType<From>
357357
: TransitionKey & keyof Props extends never
358358
? ToValues<Props, Fwd>

packages/types/util.d.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,10 @@ type LeafFunctionComponent<P> = {
146146
displayName?: string
147147
}
148148

149-
export type ComponentPropsWithRef<
150-
T extends ElementType
151-
> = T extends React.ComponentClass<infer P>
152-
? React.PropsWithoutRef<P> & React.RefAttributes<InstanceType<T>>
153-
: React.PropsWithRef<React.ComponentProps<T>>
149+
export type ComponentPropsWithRef<T extends ElementType> =
150+
T extends React.ComponentClass<infer P>
151+
? React.PropsWithoutRef<P> & React.RefAttributes<InstanceType<T>>
152+
: React.PropsWithRef<React.ComponentProps<T>>
154153

155154
// In @types/react, a "children" prop is required by the "FunctionComponent" type.
156155
export type ComponentType<P = {}> =

0 commit comments

Comments
 (0)