From eb927984aae2ac96c0ab34845c5a70275bf28269 Mon Sep 17 00:00:00 2001 From: ankit-tailor Date: Tue, 26 Sep 2023 16:22:46 +0530 Subject: [PATCH] fix: type error for components without plugin --- packages/react/src/styled.tsx | 12 +--- packages/react/src/types.ts | 104 ++++++++++++++++++---------------- 2 files changed, 56 insertions(+), 60 deletions(-) diff --git a/packages/react/src/styled.tsx b/packages/react/src/styled.tsx index bd918ca5e..6168021a1 100644 --- a/packages/react/src/styled.tsx +++ b/packages/react/src/styled.tsx @@ -823,7 +823,7 @@ const getStyleIdsFromMap = ( return componentStyleObject; }; -export function verboseStyled( +export function verboseStyled( Component: React.ComponentType

, theme: Partial>, componentStyleConfig: IComponentStyleConfig = {}, @@ -992,15 +992,7 @@ export function verboseStyled( ...componentProps }: Omit< Omit & - Partial< - ComponentProps< - ITypeReactNativeStyles, - Variants, - P, - ComCon, - PluginType - > - > & + Partial> & Partial> & { as?: any; children?: any; diff --git a/packages/react/src/types.ts b/packages/react/src/types.ts index 21b0c641b..57ec92d03 100644 --- a/packages/react/src/types.ts +++ b/packages/react/src/types.ts @@ -307,8 +307,8 @@ export type ITheme = Partial< 'animationComponentGluestack' extends keyof P ? P['animationComponentGluestack'] extends true ? Plugins - : unknown - : unknown + : [] + : [] > >; @@ -444,7 +444,7 @@ export type SxProps< GenericComponentProps = unknown, PLATFORM = '', MediaQuery = '', - PluginType = unknown + PluginType = [] > = | Partial< StylePropsType & @@ -736,53 +736,57 @@ export interface GSConfig /********************* COMPONENT PROPS TYPE *****************************************/ -export type ComponentProps< - GenericComponentStyles, - Variants, - P, - ComCon, - PluginType -> = SxStyleProps & { - 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 - : { - [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 = + 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 + : { + [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 = TokenizedRNStyleProps< GetRNStyles