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

Commit

Permalink
fix: create style typings
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-tailor committed Sep 25, 2023
1 parent 0d5e7e3 commit 4c5df7e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions packages/react/src/createStyle.ts
Original file line number Diff line number Diff line change
@@ -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 = <T, Variants>(
theme: T & ITheme<Variants, ViewProps | ImageProps | TextProps>,
theme: T | ITheme<Variants, ViewProps | ImageProps | TextProps>,
componentConfig?: Omit<IComponentStyleConfig, 'componentName'>,
BUILD_TIME_PARAMS?: any
) => {
Expand All @@ -13,7 +17,9 @@ export const createStyle = <T, Variants>(
};

return createdStyles as {
theme: T & ITheme<Variants, ViewProps | ImageProps | TextProps>;
theme: UnionToIntersection<
T | ITheme<Variants, ViewProps | ImageProps | TextProps>
>;
componentConfig?: Omit<IComponentStyleConfig, 'componentName'>;
};
};
6 changes: 3 additions & 3 deletions packages/react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -767,9 +767,9 @@ export type RNStyles<GenericComponentStyles> = TokenizedRNStyleProps<
>
>;

type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
k: infer I
) => void
export type UnionToIntersection<U> = (
U extends any ? (k: U) => void : never
) extends (k: infer I) => void
? I
: never;

Expand Down

0 comments on commit 4c5df7e

Please sign in to comment.