-
-
Notifications
You must be signed in to change notification settings - Fork 399
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
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
Theme
interface didn't match tounknown
theme type.So I think
any
type would be better in this case.