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

[docs] Add simple list typescript demo #14485

Merged
merged 2 commits into from
Mar 2, 2019
Merged

Conversation

eps1lon
Copy link
Member

@eps1lon eps1lon commented Feb 10, 2019

Testing #11731

@eps1lon eps1lon added the docs Improvements or additions to the documentation label Feb 10, 2019
It's already a pretty challenging demo if one wants to infer what
DOM node will actually be rendered and therefore what DOM
attributes are allowed. `button` would render a button but the
component overrides that again...
@mui-pr-bot
Copy link

No bundle size changes comparing 56fcebb...4d1847c

Generated by 🚫 dangerJS against 4d1847c

});

function ListItemLink(props: ListItemProps<'a', { button?: true }>) {
return <ListItem button component="a" {...props} />;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pelotom I guess this is somewhat better than before. It's not truly accurate because I would not be able to use <ListItemLink component="span" /> but I guess the tradeoff is somewhat ok. I think it's even good to forbid this because it limits the amount of places people would change what DOM node is rendered.

ListItemProps<'a', { button?: true }> is however accurate for <ListItem {...props} button component="a"/>.

I tried it with union props but gave up at some point. ListItem is just a monster when it comes to "what DOM node will be rendered?". I'll look into a simpler component and see if we can simplify those types with union props. I'm suspecting that this will still cause implicit any in callbacks because type inference works differently in JSX.

@eps1lon eps1lon merged commit ecc2c85 into mui:next Mar 2, 2019
@eps1lon eps1lon deleted the docs/list-demos-in-ts branch March 2, 2019 14:20
@eps1lon eps1lon mentioned this pull request Mar 15, 2019
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 typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants