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

unable to styled ListItem (typescript definition) #26469

Closed
2 tasks done
dabretin opened this issue May 27, 2021 · 4 comments · Fixed by #26446
Closed
2 tasks done

unable to styled ListItem (typescript definition) #26469

dabretin opened this issue May 27, 2021 · 4 comments · Fixed by #26446
Labels
bug 🐛 Something doesn't work component: list This is the name of the generic UI component, not the React module! typescript

Comments

@dabretin
Copy link
Contributor

I think it's not possible to styled ListItem because of the typescript definition of ListItemProps

  • The issue is present in the latest release.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Current Behavior 😯

image
Okayyy it's really for showing the problem, the real goal is to styled the ListItem without using sx props -it will be a library component that let the user potentially use the sx props-.

Context 🔦

Your Environment 🌎

@types/react...17.0.8
@types/react-dom...17.0.5
typescript...4.3.2
@emotion/core...11.0.0
@emotion/react...11.4.0
@emotion/styled...11.3.0
@material-ui/[email protected]
@material-ui/[email protected]
@material-ui/[email protected]
react...17.0.2
react-dom...17.0.2

@dabretin dabretin added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label May 27, 2021
@dabretin
Copy link
Contributor Author

dabretin commented May 27, 2021

Perhaps I'm completly wrong but I have to try ;)
The typescript definition of ListItem is an OverridableComponent (with li as DefaultComponent) or an extension of ButtonBase (defined with the button property).
The definition explicitly need the two (look here)... Is the & must not be an | ?

@siriwatknp
Copy link
Member

We are working on extracting button out of ListItem in #26442

@siriwatknp siriwatknp added bug 🐛 Something doesn't work component: list This is the name of the generic UI component, not the React module! labels Jun 3, 2021
@siriwatknp
Copy link
Member

siriwatknp commented Jun 4, 2021

This will be fixed once #26446 merged. However, this will still be an issue.

const StyledListItem = styled(ListItem)

// @ts-expect-error
<StyledListItem button>

I think it is okay because we are deprecating button prop in v5 in favor of ListItemButton.

@oliviertassinari oliviertassinari added typescript and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jun 27, 2021
@oliviertassinari
Copy link
Member

Otherwise, an alternative solution #13921 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: list This is the name of the generic UI component, not the React module! typescript
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants