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

CreateCSSProperties is not assignable to CSSProperties after upgrading to 4.0.2 #16198

Closed
zhaoyi0113 opened this issue Jun 13, 2019 · 3 comments · Fixed by #16200
Closed

CreateCSSProperties is not assignable to CSSProperties after upgrading to 4.0.2 #16198

zhaoyi0113 opened this issue Jun 13, 2019 · 3 comments · Fixed by #16200

Comments

@zhaoyi0113
Copy link

I found CreateCSSProperties is not assignable to CSSProperties after upgrading to 4.0.2.
Below is my code:

import { withStyles, createStyles } from '@material-ui/core/styles';
const styles = createStyles({
  logo: {
    position: 'fixed',
    top: 0,
    height: '4rem',
    backgroundColor: '#28064A',
    width: '100%',
    alignItems: 'center',
    paddingLeft: '0.5rem',
    zIndex: 1
  }
}

...
   <MenuIcon styles={styles.logo} />
...

The styles of MenuIcon is type of styles?: React.CSSProperties;. I get this error:

TS2322: Type 'CreateCSSProperties<{}> | ((props: {}) => CreateCSSProperties<{}>)' is not assignable to type 'CSSProperties | undefined'.
  Type 'CreateCSSProperties<{}>' is not assignable to type 'CSSProperties'

It seems that after 4.0.2 createStyles returns a type which is not compatible with React.CSSProperties. Is there a quick way to fix it?

@merceyz
Copy link
Member

merceyz commented Jun 13, 2019

Working on a fix.

Is there a quick way to fix it?

Cast the result from createStyles would be the easiest

@zhaoyi0113
Copy link
Author

so you mean using as any?

@merceyz
Copy link
Member

merceyz commented Jun 13, 2019

I was thinking more of styles.logo as CSSProperties but yeah, you can do that as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants