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

update type definition for ListItem. #15779

Conversation

amarjeetalien
Copy link

The current type definition show error when using LitsItem and not passing the button flag. Which is very obvious from the below line:

declare const ListItem: OverridableComponent<ListItemTypeMap<{ button?: false }, 'li'>> &
  ExtendButtonBase<ListItemTypeMap<{ button: true }, 'div'>>;

button as false

image

Not passisng it

image

The current `type` definition show error when using LitsItem and not passing the `button` flag.
@mui-pr-bot
Copy link

No bundle size changes comparing f32d82e...67b0ae9

Generated by 🚫 dangerJS against 67b0ae9

@eps1lon
Copy link
Member

eps1lon commented May 21, 2019

Could you include the code that is failing please? The overloads are intended to not have any overlap so it's not obvious that this needs to be changed.

@amarjeetalien
Copy link
Author

amarjeetalien commented May 22, 2019

@eps1lon

Could you include the code that is failing please? The overloads are intended to not have any overlap so it's not obvious that this needs to be changed.

Code sample is as below:

const LegendButton = (legendColor: string) =>
  withStyles({
    root: {
      color: legendColor,
    },
    gutters: {
      paddingLeft: spaces[1],
      paddingRight: spaces[1],
    },
  })(ListItem);

const MyLegend: FC<{ legendColor: string }> = ({ legendColor}) => {
  const Legend = LegendButton(legendColor);

  return (
    <Legend> // build fails at this line with TSLint reporting error as shown in above screenshots
      <IconButton>
        <DotIcon />
      </IconButton>
      <ListItemText primary={legendName} />
    </Legend>
  );
};

It works only if I pass button.

<Legend button>

I tried something like below, but this also reports the error:

const isButton = false;
<Legend button={isButton}>

image

@eps1lon
Copy link
Member

eps1lon commented May 22, 2019

That is an issue with higher-order components and some of our typings. Essentially a duplicate of #15759. The underlying issue is microsoft/TypeScript#26591.

I recommend using withStyles(styles)(SomeMuiComponent) as SomeMuiComponent.

@eps1lon eps1lon closed this May 22, 2019
@eps1lon eps1lon added duplicate This issue or pull request already exists and removed status: waiting for author Issue with insufficient information labels May 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants