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

[Typescript] ListSubheader reject ListItem as component prop #17699

Closed
2 tasks done
cvolant opened this issue Oct 4, 2019 · 2 comments · Fixed by #17715
Closed
2 tasks done

[Typescript] ListSubheader reject ListItem as component prop #17699

cvolant opened this issue Oct 4, 2019 · 2 comments · Fixed by #17715

Comments

@cvolant
Copy link

cvolant commented Oct 4, 2019

"No overload matches this call."

  • 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 😯

Raise a typescript error.

Expected Behavior 🤔

Accept the following props without complaining:

<ListSubheader component={ListItem} divider>

Steps to Reproduce 🕹

https://codesandbox.io/s/create-react-app-with-typescript-c7fcp

Steps:

  1. Try this with typescript enabled:
<ListSubheader component={ListItem} divider>
  1. See this frustrating red line under ListSubheader?

Context

I ran into this trying to make the subheader similar to my list items.
It works well, but I wondered why was typescript complaining. I checked the docs that say:

If you encounter a component that rejects its component props in TypeScript please open an issue.

So here it is.

Your Environment 🌎

Tech Version
Material-UI latest
React 16.9.0
IDE VSCode
TypeScript 3.6.3
sakulstra added a commit to sakulstra/material-ui that referenced this issue Oct 5, 2019
@sakulstra
Copy link
Contributor

i'm taking a look at this, as i'm just learning typescript so it makes sense for me to read trough what you guys are doing 👏

@oliviertassinari
Copy link
Member

oliviertassinari commented Oct 18, 2019

On a side note, the issue use case looks wrong. I would discourage to render anything else than native element with the component prop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants