-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[typescript] Material UI components are incompatible to emotion and styled-components #14191
Comments
I cannot reproduce the error for Edit: I get a different error though. Will work on a fix. |
I'm using "@types/react": "^16.7.20" and "@types/styled-components": "^4.1.6". Here is the exact error message from a styled icon with styled components:
This is my tsconfig.json
|
I THINK the comment from @Jessidhia here DefinitelyTyped/DefinitelyTyped#29832 (comment) is the best description of the problem. As soon as i edit |
…ility with material ui. More explained in mui/material-ui#14191
I still see the issue in 4.0.0-beta.1 The merge message contains some information about a css prop in the documentation? Yet all I can find there is
|
@Mario-Eis We have type tests for latest emotion and material-ui types that pass. Please open a separate issue with the code that is failing. |
I posted a demo project in #15609 |
When using styled components >=4.1.0 or emotion >=10 there will be type errors if material ui components are styled.
The reason seems to be the usage of React.ComponentType that is weather ComponentClass OR FunctionComponent but not explicitly typed.
I think this should be related to DefinitelyTyped/DefinitelyTyped#29832 and possibly DefinitelyTyped/DefinitelyTyped#30942 on styled components side. And emotion-js/emotion#1167 on emotions side.
There are possible workarounds, but they all require to bypass type checking by e.g. casting to any. As if that is not bad enough, it has to be done for all styled components individually. In a very large code base this means to implement a workaround in many (many!) places.
Expected Behavior 🤔
No build or type errors are expected when styling material ui components with styled components or emotion.
Current Behavior 😯
A lot of type errors like:
Steps to Reproduce 🕹
Just do something simple like
and use StyledTypography in a render function passing a prop like color. Typescript will throw errors.
So far, any material ui component I tried, was affected.
Your Environment 🌎
The text was updated successfully, but these errors were encountered: