mui / material-ui

Material UI: Ready-to-use foundational React components, free forever. It includes Material UI, which implements Google's Material Design.
https://mui.com/material-ui/
MIT License
92.42k stars 31.84k forks source link

SASS style child selectors no longer work since csstype dependency #11640

Closed stubar closed 5 years ago

stubar commented 6 years ago

React.CSSProperties now relies csstype as of the 8th of May (see https://www.npmjs.com/package/@types/react). So now my following code doesn't work...

const styles = (myTheme: Theme): StyleRules<string> => ({
  root: {
    marginLeft: myTheme.spacing.unit,
    marginRight: myTheme.spacing.unit,
    minWidth: 250,
    maxWidth: 350,
    flex: 1,
    margin: "8px 0",
    "& > *": {
      width: "100%"
    }
  }
});

since it is using "& > *" which isn't regular css. Are https://github.com/cssinjs/jss-nested nested style selectors no longer supported? (Or maybe they never were?)

I'm also getting "Type 'PaletteColor' is not assignable to type 'string'." for the following code...

info: {
    color: myTheme.palette.primary
  },

not sure if related but it's started occurring at the same time.

Expected Behavior

above code to work after upgrading "@types/react"

Current Behavior

build fails due to typescript error

Steps to Reproduce (for bugs)

  1. create a nested withStyles rule
  2. upgrade "@types/react" to 16.3.14
  3. compile in typescript

Context

Your Environment

Tech Version
Material-UI 1.0.0-beta.38
React 16.3.2
browser
etc
eps1lon commented 5 years ago

This is working in @material-ui/core@3.1.0 when using it like this:

import { createStyles, Theme } from "@material-ui/core/styles";

const styles = (myTheme: Theme) => createStyles({
  root: {
    marginLeft: myTheme.spacing.unit,
    marginRight: myTheme.spacing.unit,
    minWidth: 250,
    maxWidth: 350,
    flex: 1,
    margin: "8px 0",
    "& > *": {
      width: "100%"
    }
  }
});

@oliviertassinari I guess this can be closed. This should even work in ^1.2.0

oliviertassinari commented 5 years ago

I guess this can be closed. This should even work in ^1.2.0

@eps1lon It's good to know.