Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TS types for variant composition #218

Merged
merged 1 commit into from
Sep 16, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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