Skip to content

[styled-engine] Infer ownerState from props in styled #46083

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

Merged
merged 1 commit into from
May 5, 2025

Conversation

siriwatknp
Copy link
Member

Issue

There is a bug from #45478.
The props is not inferred from the ownerState values

type OwnerState = {
  variant?: 'success' | 'error' | 'processing';
  showChanges: boolean;
};

const VariantObjects = styled('div')<{ ownerState: OwnerState } & OwnerState>({
  font: 'inherit',
  color: 'inherit',
  variants: [
    {
      props: { variant: 'success' }, // ❌ variant is not inferred from the `ownerState`
      style: {
        color: 'red',
      },
    },
  ],
});

Found this when trying the master build on MUI X.

@siriwatknp siriwatknp added typescript package: styled-engine Specific to @mui/styled-engine labels May 5, 2025
@siriwatknp siriwatknp requested review from mnajdova and DiegoAndai May 5, 2025 04:08
@mui-bot
Copy link

mui-bot commented May 5, 2025

Netlify deploy preview

https://deploy-preview-46083--material-ui.netlify.app/

Bundle size report

No bundle size changes (Toolpad)
No bundle size changes

Generated by 🚫 dangerJS against 5f6282b

@siriwatknp siriwatknp merged commit 691a09b into mui:master May 5, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: styled-engine Specific to @mui/styled-engine typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants