You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, in strict mode Typescript will complain that Parameter 'props' implicitly has an 'any' type, because it's unable to infer the props argument's type. This can be fixed by explicitly providing the type:
Perhaps there is already a way to do this? The Typescript section of the v10.0.4 docs is empty, so perhaps the resolution to my issue is to fill out that section. I'm happy to write a bit for the docs, though I need to understand how the types function first!
Versions (please complete the following information):
jss: 10.0.4
Browser [e.g. chrome, safari]: n/a
OS [e.g. Windows, macOS]: macOS
Feel free to add any additional versions which you may think are relevant to the bug.
The text was updated successfully, but these errors were encountered:
Also it would be great to have CardProps from example above as expected type of useStyles function param (props): const styles = useStyles(props)
It expects data?: unknown param now and we can provide data (props) with any type or do not provide it at all. So classes generation can be broken if we will not provide data. But typescript will not catch this mistake
This approach "works" but it is extremely clunky and verbose.
I have run in to a similar TS issue when trying to use a theme, since the component has no idea what it is in the theme provided:
This gives an error of "Unsafe member access .primaryBlue on an any value" since the theme is not typed, even if I specify that theme is of type Styles(from react-jss types).
Expected behavior:
A dynamic style that uses React props should be able to get the type of the props for use in the style rule.
Describe the bug:
Consider the following basic component:
Using JSS this can be refactored:
However, in strict mode Typescript will complain that
Parameter 'props' implicitly has an 'any' type
, because it's unable to infer theprops
argument's type. This can be fixed by explicitly providing the type:But this won't scale well if there are other dynamic styles:
It would be great if there were a way to inform
createUseStyles
what theprops
type will be. For example:Perhaps there is already a way to do this? The Typescript section of the v10.0.4 docs is empty, so perhaps the resolution to my issue is to fill out that section. I'm happy to write a bit for the docs, though I need to understand how the types function first!
Versions (please complete the following information):
Feel free to add any additional versions which you may think are relevant to the bug.
The text was updated successfully, but these errors were encountered: