Material-ui: Use of ListItemClasses prop on MenuItem component leads to typescript compilation crash. (No overload matches this call)

Created on 15 Jul 2020  路  2Comments  路  Source: mui-org/material-ui

Hello guys and thank you for you awesome lib.

Typescript compiler does not recognize ListItemClasses prop on MenuItem component.
The error exists only on Typescript project not on plain js/jsx. (works as expected)
It seems that something wrong is happening with Typescript declaration related to ListItemClasses.

The above error presented when i use the ListItemClasses prop.

ERROR
/home/mike/Workspace/list-item-classes/src/MyMenu.tsx
TypeScript error in /home/mkarasavvas/Workspace/list-item-classes/src/MyMenu.tsx(34,39):
No overload matches this call.
The last overload gave the following error.
Type '{ children: string; onClick: () => void; ListItemClasses: { root: string; }; }' is not assignable to type 'IntrinsicAttributes & { button?: true | undefined; } & { alignItems?: "center" | "flex-start" | undefined; autoFocus?: boolean | undefined; button?: boolean | undefined; ... 7 more ...; selected?: boolean | undefined; } & { ...; } & CommonProps<...> & Pick<...>'.
Property 'ListItemClasses' does not exist on type 'IntrinsicAttributes & { button?: true | undefined; } & { alignItems?: "center" | "flex-start" | undefined; autoFocus?: boolean | undefined; button?: boolean | undefined; ... 7 more ...; selected?: boolean | undefined; } & { ...; } & CommonProps<...> & Pick<...>'. TS2769

DETAILS
I found that this happened after the commit with hash 242080f08cd8b5a342b86299c58494bd3edce85d (3rd July)

On that commit 65d036e8aab5e0fe9e3efbf788daa8af8db57757 (2nd July) the ListItemClasses works as expected on Typescript.

_package.json_
"dependencies": {
"@material-ui/core": "^4.11.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"@types/jest": "^24.9.1",
"@types/node": "^12.12.50",
"@types/react": "^16.9.43",
"@types/react-dom": "^16.9.8",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1",
"typescript": "^3.7.5"
},

Menu typescript

Most helpful comment

Same issue here. Thank you @karasavm for pointing out the commit that works.

All 2 comments

Same issue here. Thank you @karasavm for pointing out the commit that works.

Is it fixed now? I'm still facing the same issue on v4.11.0

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anthony-dandrea picture anthony-dandrea  路  3Comments

newoga picture newoga  路  3Comments

mattmiddlesworth picture mattmiddlesworth  路  3Comments

pola88 picture pola88  路  3Comments

ryanflorence picture ryanflorence  路  3Comments