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
[TS] From @types/react 16.3.9 React.CSSProperties is strongly typed #11004
Comments
Actually to get even better typing something as lame as this (typescript cannot make circular types :( ) would be preferred
that way you get strong typing for standard properties up to 10 levels deep, further than that anything goes |
Where exactly in Material UI are you proposing a change, or is this an issue with |
As noted here: https://github.com/frenic/csstype#what-should-i-to-do-when-i-get-type-errors I am now using the following type augmentation import * as CSS from 'csstype'
declare module 'csstype' {
interface Properties {
// Add a CSS Custom Property
'&:hover'?: Properties<string | number>
// ...or allow any other property
// [index: string]: any
}
} For one-offs where I use jss syntax, I'm casting as any (mentioned by @pelotom in DefinitelyTyped/DefinitelyTyped#24911): const styles = withStyles<FooClassKey>(theme => ({
listItem: {
['&:hover $listItemIcon' as any]: {
visibility: 'inherit',
},
},
})) |
Module augmentation/casting definitely shouldn't be required for this. This is a bug in either |
I've opened a PR: #11007. |
From types/react 16.3.9 react now uses csstypes as a package for CSSProperties, which is strongly typed
This means that types for themes that used to rely on the fallback
[k: string]: any
for stuff such as "&:hover" gives now errors.For those cases it should use something like
The text was updated successfully, but these errors were encountered: