Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
fix: component and style prop conflict typing
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-tailor committed Oct 16, 2023
1 parent 86af071 commit f3fb15e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 60 deletions.
8 changes: 1 addition & 7 deletions packages/react/src/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type {
OrderedSXResolved,
StyleIds,
ComponentProps,
UtilityProps,
IVerbosedTheme,
ITheme,
ExtendedConfigType,
Expand Down Expand Up @@ -996,12 +995,7 @@ export function verboseStyled<P, Variants, ComCon>(
// sxHash: BUILD_TIME_sxHash = '',
...componentProps
}: Omit<
Omit<P, keyof Variants> &
Partial<ComponentProps<ITypeReactNativeStyles, Variants, P, ComCon>> &
Partial<UtilityProps<ITypeReactNativeStyles>> & {
as?: any;
children?: any;
},
ComponentProps<ITypeReactNativeStyles, Variants, P, ComCon>,
'animationComponentGluestack'
>,
ref: React.ForwardedRef<P>
Expand Down
116 changes: 63 additions & 53 deletions packages/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -735,61 +735,71 @@ interface GenericComponents {
/********************* COMPONENT PROPS TYPE *****************************************/

export type ComponentProps<GenericComponentStyles, Variants, P, ComCon> =
SxStyleProps<
GenericComponentStyles,
Variants,
P,
'animationComponentGluestack' extends keyof P
? P['animationComponentGluestack'] extends true
? Plugins
: []
: []
> & {
states?: {
[K in IState]?: boolean;
};
} & (GSConfig['globalStyle'] extends object
? {
[Key in keyof MergeNestedThree<
GlobalVariants,
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>]?: keyof MergeNestedThree<
GlobalVariants,
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>[Key] extends 'true' | 'false'
? boolean
: keyof MergeNestedThree<
GlobalVariants,
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>[Key];
} & Omit<P, keyof Variants>
: {
[Key in keyof MergeNested<
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>]?: keyof MergeNested<
Variants, // @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>[Key] extends 'true' | 'false'
? boolean
: keyof MergeNested<
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>[Key];
});
Partial<
Omit<P, keyof Variants> &
SxStyleProps<
GenericComponentStyles,
Variants,
P,
'animationComponentGluestack' extends keyof P
? P['animationComponentGluestack'] extends true
? Plugins
: []
: []
> & {
as?: any;
children?: any;
} & UtilityProps<GenericComponentStyles, P> & {
states?: {
[K in IState]?: boolean;
};
} & (GSConfig['globalStyle'] extends object
? {
[Key in keyof MergeNestedThree<
GlobalVariants,
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>]?: keyof MergeNestedThree<
GlobalVariants,
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>[Key] extends 'true' | 'false'
? boolean
: keyof MergeNestedThree<
GlobalVariants,
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>[Key];
} & Omit<P, keyof Variants>
: {
[Key in keyof MergeNested<
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>]?: keyof MergeNested<
Variants, // @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>[Key] extends 'true' | 'false'
? boolean
: keyof MergeNested<
Variants,
// @ts-ignore
Components[`${ComCon}`]['theme']['variants']
>[Key];
})
>;

export type UtilityProps<GenericComponentStyles> = TokenizedRNStyleProps<
GetRNStyles<GenericComponentStyles>
export type UtilityProps<GenericComponentStyles, GenericComponentProps> = Omit<
TokenizedRNStyleProps<GetRNStyles<GenericComponentStyles>>,
keyof GenericComponentProps
> &
AliasesProps<RNStyles<GenericComponentStyles>>;
Omit<
AliasesProps<RNStyles<GenericComponentStyles>>,
keyof GenericComponentProps
>;

/********************* UTILITY TYPE *****************************************/

Expand Down

0 comments on commit f3fb15e

Please sign in to comment.