Skip to content

Commit

Permalink
Reduce complexity of FullProps type
Browse files Browse the repository at this point in the history
  • Loading branch information
MattSchiller authored Apr 18, 2024
1 parent 31cca29 commit 3708019
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,7 @@ interface PureFunctionComponent<P = {}> {
export type SetupComponentType = React.ComponentType<any> | PureFunctionComponent;

// Given a C component type, extracts the props of it:
// * If C is an explicitly declared React.Component subclass or React.FC, we can use React.ComponentProps
// * Otherewise if it's a regular function, we can extract its first parameter as the props
// * If not, we give up...
export type FullProps<C extends SetupComponentType> = C extends React.ComponentType
? React.ComponentProps<C>
: C extends PureFunctionComponent
? Parameters<C>[0]
: unknown;
export type FullProps<C extends SetupComponentType> = React.ComponentProps<C>

export type RenderEnzyme<
Component extends SetupComponentType,
Expand Down

0 comments on commit 3708019

Please sign in to comment.