Skip to content

Commit

Permalink
Fix TS types for variant composition
Browse files Browse the repository at this point in the history
  • Loading branch information
jjenzz committed Sep 16, 2020
1 parent cd4a13e commit 683a27f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/react/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,14 @@ export type TStyled<Config extends TConfig> = {
// tslint:disable-next-line: callable-types
<
TagOrComponent extends keyof JSX.IntrinsicElements | React.ComponentType<any> | IStyledComponent<any, any, Config>,
BaseAndVariantStyles extends TComponentStylesObject<Config>
BaseAndVariantStyles extends TComponentStylesObject<Config>,
Variants = TExtractVariants<BaseAndVariantStyles>
>(
tag: TagOrComponent,
baseStyles: BaseAndVariantStyles | TComponentStylesObject<Config>
): TagOrComponent extends IStyledComponent<any, any, Config>
? TagOrComponent
: IStyledComponent<TagOrComponent, TExtractVariants<BaseAndVariantStyles>, Config>;
): TagOrComponent extends IStyledComponent<infer T, infer V, Config>
? IStyledComponent<T, Omit<V, keyof Variants> & Variants, Config>
: IStyledComponent<TagOrComponent, Variants, Config>;
} & TProxyStyledElements<Config>;

const createCompoundVariantsMatcher = (breakPoints: any, existingMap?: any) => {
Expand Down

0 comments on commit 683a27f

Please sign in to comment.