From 4c5df7eb8b59226e2bddbb5018ed993de714d985 Mon Sep 17 00:00:00 2001 From: ankit-tailor Date: Mon, 25 Sep 2023 19:00:30 +0530 Subject: [PATCH] fix: create style typings --- packages/react/src/createStyle.ts | 12 +++++++++--- packages/react/src/types.ts | 6 +++--- 2 files changed, 12 insertions(+), 6 deletions(-) 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;