Skip to content

Typescript: in ListItem, property button is no more boolean #14971

@sveyret

Description

@sveyret

The following code in not compiling anymore in mui v4.0:

<ListItem button={editable} >
  <ListItemText primary="text" />
</ListItem>

where editable is a boolean value.

  • This is not a v0.x issue.
  • I have searched the issues of this repository and believe that this is not a duplicate.

Expected Behavior 🤔

Should compile without error.

Current Behavior 😯

Type 'boolean' is not assignable to type 'true'.

button={editable}

../../../node_modules/@material-ui/core/ListItem/ListItem.d.ts:23:38
23 ExtendButtonBase<ListItemTypeMap<{ button: true }, 'div'>>;

The expected type comes from property 'button' which is declared here on type 'IntrinsicAttributes & { action?: ((actions: ButtonBaseActions) => void) | undefined; buttonRef?: ((instance: any) => void) | RefObject | null | undefined; centerRipple?: boolean | undefined; ... 6 more ...; TouchRippleProps?: Partial<...> | undefined; } & { ...; } & { ...; } & CommonProps<...> & Pick<...>'

Your Environment 🌎

Tech Version
Material-UI 4.0.0-alpha.4
React 16.8.4
@types/react 16.8.8
TypeScript 3.3.3333

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions