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

fix: component and style prop conflict typing #479

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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