Skip to content

[styled-engine-sc] Fix types for components extended with styled #45988

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
30 changes: 27 additions & 3 deletions packages/mui-styled-engine-sc/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,7 @@ export type StyledComponent<
// any doesn't count as assignable to never in the extends clause, and we default A to never
export type AnyStyledComponent =
| StyledComponent<any, any, any, any>
| StyledComponent<any, any, any>
| React.FunctionComponent<any>
| React.ComponentType<any>;
| StyledComponent<any, any, any>;

export type StyledComponentInnerComponent<C extends AnyStyledComponent> =
C extends StyledComponent<infer I, any, any, any>
Expand Down Expand Up @@ -320,6 +318,32 @@ export interface ThemedBaseStyledInterface<
MuiStyledOptions extends object,
Theme extends object,
> extends ThemedStyledComponentFactories<Theme> {
<
C extends AnyStyledComponent,
ForwardedProps extends keyof PropsOf<StyledComponentInnerComponent<C>> = keyof PropsOf<
StyledComponentInnerComponent<C>
>,
>(
component: C,
options: FilteringStyledOptions<PropsOf<StyledComponentInnerComponent<C>>, ForwardedProps> &
MuiStyledOptions,
): CreateStyledComponent<
Pick<PropsOf<StyledComponentInnerComponent<C>>, ForwardedProps>,
StyledComponentInnerOtherProps<C>,
{},
Theme
>;

<C extends AnyStyledComponent>(
component: C,
options?: StyledConfig<PropsOf<StyledComponentInnerComponent<C>>> & MuiStyledOptions,
): CreateStyledComponent<
PropsOf<StyledComponentInnerComponent<C>>,
StyledComponentInnerOtherProps<C>,
{},
Theme
>;

<
C extends React.ComponentClass<React.ComponentProps<C>>,
ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>,
Expand Down
Loading