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

MenuItem & MenuItemProps -> No overload matches this call #21127

Closed
2 tasks done
B3Kay opened this issue May 20, 2020 · 2 comments
Closed
2 tasks done

MenuItem & MenuItemProps -> No overload matches this call #21127

B3Kay opened this issue May 20, 2020 · 2 comments
Labels
component: menu This is the name of the generic UI component, not the React module! typescript

Comments

@B3Kay
Copy link

B3Kay commented May 20, 2020

Summary

Trying to export MenuItem from my own lib, but get typescript: semantic error TS2769.

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

Code:

import React from 'react';
import MuiMenuItem, { MenuItemProps } from '@material-ui/core/MenuItem';

export const MenuItem = (props: MenuItemProps): JSX.Element => <MuiMenuItem {...props} />;

Èrror on compile:

[!] (plugin rpt2) Error: /home/b3kay/jobb/astrazeneca/csp-frontend/packages/csp-web-ui/src/components/MenuItem/MenuItem.tsx(4,65): semantic error TS2769: No overload matches this call.
  The last overload gave the following error.
    Type '{ alignItems?: "flex-start" | "center" | undefined; autoFocus?: boolean | undefined; button?: boolean | undefined; ContainerComponent?: "object" | "abbr" | "address" | "article" | ... 76 more ... | undefined; ... 266 more ...; css?: InterpolationWithTheme<...>; }' is not assignable to type '{ button?: true | undefined; }'.
      Types of property 'button' are incompatible.
        Type 'boolean | undefined' is not assignable to type 'true | undefined'.
          Type 'false' is not assignable to type 'true | undefined'.

Expected Behavior 🤔

Should not give an error...

Steps to Reproduce 🕹

Material-recommended Codesandbox:
https://codesandbox.io/s/goofy-mcclintock-tz9z9?file=/src/MenuItem.tsx
CRA Typescript sandbox:
https://codesandbox.io/s/react-typescript-82spk?file=/src/MenuItem.tsx:0-203

Context 🔦

I'm building a component library and want to export Material-ui components from there as a middle layer instead of direct from Material-ui.
Other components work for example:

import { InputLabel as MuiInputLabel, InputLabelProps } from '@material-ui/core';

export const InputLabel = (props: InputLabelProps): JSX.Element => <MuiInputLabel {...props} />;

Your Environment 🌎

It doesn't seem to be environment dependant. Get the same error in the sandbox.

Tech Version
Material-UI v4.9.14
React v16.11.0
"rollup-plugin-typescript2 ^0.27.0
@oliviertassinari oliviertassinari added typescript component: menu This is the name of the generic UI component, not the React module! labels May 20, 2020
@oliviertassinari
Copy link
Member

@B3Kay Thanks for the reproduction.
This issue could be part of a large issue we have with extending component. The Slider has a similar one in #20191.

@eps1lon
Copy link
Member

eps1lon commented May 25, 2020

Duplicate of #14971

@eps1lon eps1lon marked this as a duplicate of #14971 May 25, 2020
@eps1lon eps1lon closed this as completed May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: menu This is the name of the generic UI component, not the React module! typescript
Projects
None yet
Development

No branches or pull requests

3 participants