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

Commit

Permalink
fix: type error for components without plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-tailor committed Sep 26, 2023
1 parent b5e4f8e commit eb92798
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 60 deletions.
12 changes: 2 additions & 10 deletions packages/react/src/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ const getStyleIdsFromMap = (
return componentStyleObject;
};

export function verboseStyled<P, Variants, ComCon, PluginType = unknown>(
export function verboseStyled<P, Variants, ComCon>(
Component: React.ComponentType<P>,
theme: Partial<IVerbosedTheme<Variants, P>>,
componentStyleConfig: IComponentStyleConfig<ComCon> = {},
Expand Down Expand Up @@ -992,15 +992,7 @@ export function verboseStyled<P, Variants, ComCon, PluginType = unknown>(
...componentProps
}: Omit<
Omit<P, keyof Variants> &
Partial<
ComponentProps<
ITypeReactNativeStyles,
Variants,
P,
ComCon,
PluginType
>
> &
Partial<ComponentProps<ITypeReactNativeStyles, Variants, P, ComCon>> &
Partial<UtilityProps<ITypeReactNativeStyles>> & {
as?: any;
children?: any;
Expand Down
104 changes: 54 additions & 50 deletions packages/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,8 @@ export type ITheme<Variants, P> = Partial<
'animationComponentGluestack' extends keyof P
? P['animationComponentGluestack'] extends true
? Plugins
: unknown
: unknown
: []
: []
>
>;

Expand Down Expand Up @@ -444,7 +444,7 @@ export type SxProps<
GenericComponentProps = unknown,
PLATFORM = '',
MediaQuery = '',
PluginType = unknown
PluginType = []
> =
| Partial<
StylePropsType<GenericComponentStyles, PLATFORM> &
Expand Down Expand Up @@ -736,53 +736,57 @@ export interface GSConfig

/********************* COMPONENT PROPS TYPE *****************************************/

export type ComponentProps<
GenericComponentStyles,
Variants,
P,
ComCon,
PluginType
> = SxStyleProps<GenericComponentStyles, Variants, P, PluginType> & {
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 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];
});

export type UtilityProps<GenericComponentStyles> = TokenizedRNStyleProps<
GetRNStyles<GenericComponentStyles>
Expand Down

0 comments on commit eb92798

Please sign in to comment.