diff --git a/packages/react/src/createStyle.ts b/packages/react/src/createStyle.ts index 72b081c85..8db8b45b3 100644 --- a/packages/react/src/createStyle.ts +++ b/packages/react/src/createStyle.ts @@ -1,8 +1,12 @@ import type { ViewProps, ImageProps, TextProps } from 'react-native'; -import type { IComponentStyleConfig, ITheme } from './types'; +import type { + IComponentStyleConfig, + ITheme, + UnionToIntersection, +} from './types'; export const createStyle = ( - theme: T & ITheme, + theme: T | ITheme, componentConfig?: Omit, BUILD_TIME_PARAMS?: any ) => { @@ -13,7 +17,9 @@ export const createStyle = ( }; return createdStyles as { - theme: T & ITheme; + theme: UnionToIntersection< + T | ITheme + >; componentConfig?: Omit; }; }; diff --git a/packages/react/src/types.ts b/packages/react/src/types.ts index 7bc99cd17..7d60ad7fc 100644 --- a/packages/react/src/types.ts +++ b/packages/react/src/types.ts @@ -767,9 +767,9 @@ export type RNStyles = TokenizedRNStyleProps< > >; -type UnionToIntersection = (U extends any ? (k: U) => void : never) extends ( - k: infer I -) => void +export type UnionToIntersection = ( + U extends any ? (k: U) => void : never +) extends (k: infer I) => void ? I : never;