-
-
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
[core] Fix mixins not being assignable as JSS styles #19491
Conversation
This change will fix an error a couple users reported when attempting to use const useStyles = makeStyles(theme => ({
appBarSpacer: theme.mixins.toolbar,
})); However, in #19263, the following change was made to allow React.CSSProperties to be assigned to the internal type CSSProperties. export interface CSSProperties extends BaseCSSProperties {
// Allow pseudo selectors and media queries
// `unknown` is used since TS does not allow assigning an interface without
// an index signature to one with an index signature. This is to allow type safe
// module augmentation.
// Technically we want any key not typed in `BaseCSSProperties` to be of type
// `CSSProperties` but this doesn't work. The index signature needs to cover
// BaseCSSProperties as well. Usually you would use `BaseCSSProperties[keyof BaseCSSProperties]`
// but this would not allow assigning React.CSSProperties to CSSProperties
[k: string]: unknown | CSSProperties;
} In other words, while this pull request will "fix" the issue. The change in withStyles.d.ts may not have worked as expected. I'm pointing this out for reference. Should this pull request be accepted, I'm happy to expand further if need be. |
No bundle size changes comparing bdebdfd...4595e49 |
@ririvas Much appreciated, thanks! |
@eps1lon Will this be released in a patch release? |
It will be in the next release. Whether this will be a patch or feature release I do not know. |
Thanks for the fast fix, this bit me. =) |
This pull request reverts one of the changes made in #19263 and addresses #19362 .
The intent of original pull request was to avoid using the CSS-in-JS (JSS) implementation specific "CSSProperties" type where the simpler React.CSSProperties can be used. However, createMixins does directly rely on ability to specify media query nested selectors, a feature not present in React.CSSProperties
This change allows us to continue to override the toolbar implementation in Typescript. Whereas it is supported in vanilla JS.