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

[Material-UI v5 alpha 32] experimentalStyled missing styleProps in typescript definition #26079

Closed
david-ic3 opened this issue May 1, 2021 · 5 comments
Labels
docs Improvements or additions to the documentation package: styled-engine Specific to @mui/styled-engine typescript

Comments

@david-ic3
Copy link

david-ic3 commented May 1, 2021

Trying to create my own component using experimentalStyled mimicking Autocomplete in typescript I got a compile error on styleProps property

<AutocompleteLoading styleProps={props}>
  This is not compiling
</AutocompleteLoading>

Property 'styleProps' does not exist on type ...

In Sandbox a simplified example https://codesandbox.io/s/interesting-babbage-zyrpz?file=/src/Demo.tsx:658-757

@david-ic3 david-ic3 added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 1, 2021
@mnajdova
Copy link
Member

mnajdova commented May 1, 2021

Thanks for the report, was fixed in #25928, will be available in the next release.

@mnajdova mnajdova closed this as completed May 1, 2021
@mnajdova mnajdova reopened this May 1, 2021
@mnajdova mnajdova added package: styled-engine Specific to @mui/styled-engine typescript labels May 1, 2021
@oliviertassinari
Copy link
Member

oliviertassinari commented May 1, 2021

Could it be seen as a duplicate of #24862?

Spreading extra props might actually be something we could document in https://next--material-ui.netlify.app/guides/styled-engine/ (in addition to the existing customization page). We currently cover it in https://next--material-ui.netlify.app/customization/how-to-customize/#dynamic-css.

@oliviertassinari oliviertassinari removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 1, 2021
@mnajdova
Copy link
Member

mnajdova commented May 1, 2021

Yeah, makes sense. 👍

@david-ic3
Copy link
Author

david-ic3 commented May 2, 2021

Thanks for the quick turnaround, I see I'm not the only one working on week-ends, guys really no need.

From a documentation side a bit around this experimentalStyle function would be welcomed as an example on how to create a composed component like an MUI one from scratch.

To get a hint what we are trying to achieve (selected is a new prop) :

function MyUselessButton(props: PropsOf<typeof Button> & {selected: boolean | undefined} ) {
    return <Button {...props} />;
}

const FilterButton = experimentalStyled(MyUselessButton, {
    shouldForwardProp: (prop) => prop !== 'selected',
})(({selected, theme}) => ({
    ...theme.components!['FilterButtons'].styleOverrides.muiButton,   // it's a bit of hack and we don't have variants
    ...selected && {backgoundColor: theme.live['selection'].selectedColor}
}));

my one cent

@oliviertassinari oliviertassinari added the docs Improvements or additions to the documentation label May 2, 2021
@mnajdova
Copy link
Member

Note, in the end we decided not to include the styleProps by default, see #26461

The main motivation was that, if developers need it, they are likely going to need to specify custom type for it, so we decided to better make it explicit, rather then implicit. As the prop is not added anymore, no need for updating the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improvements or additions to the documentation package: styled-engine Specific to @mui/styled-engine typescript
Projects
None yet
Development

No branches or pull requests

3 participants