fix(react-jss): fix react-jss theme types#1349
Conversation
|
Is this the best way to do it in ts? Is user able to define a strict theme? It sounds like it should be a generic but I only use flowtype, so I have no idea |
Of course we can add second generic for WithStylesProps to specify theme object in more strict way. interface WithStylesProps<S extends Styles | ((theme: T) => Styles), T> {
classes: Classes<S extends ((theme: T) => Styles) ? keyof ReturnType<S> : keyof S>
}But, actually, we don't need this Theme generic to calculate our classes result. interface Props extends WithStylesProps<typeof styles, Theme> {}vs interface Props extends WithStylesProps<typeof styles> {} |
|
Mb I misunderstand something, is user able to specify the theme type right now and let ts show this type everywhere it is used? |
|
In my app I have a Theme interface and use it while defining of dynamic styles for component. const styles = (theme: Theme) => {...} |
|
I agree. We should change theme type to // ↧ this one
interface WithStylesProps<S extends Styles | ((theme: any) => Styles)> {
classes: Classes<S extends ((theme: any) => Styles) ? keyof ReturnType<S> : keyof S>
} |
|
Alright, merged! |
Great! Can you tell me how frequently new versions of |

What would you like to add/fix?
The problem is that my app
Themeinterface didn't match tounknowntheme type.So I think
anytype would be better in this case.