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
It's not possible to type props of createStyles or makeStyles while still inferring the class names.
The issue is present in the latest release.
I have searched the issues of this repository and believe that this is not a duplicate.
Current Behavior 😯
Using makeStyles<Theme, SomeProps> will result in Record<string, string> as it's return-value.
I don't have to even try createStyles since the class names come as the first generic type and are not optional.
Expected Behavior 🤔
To be able to type props of makeStyles or createStyles without loosing inference of the class names.
makeStyles with two generic params expects the ClassKey as the second param: export default function makeStyles<Theme = DefaultTheme, ClassKey extends string = string>
If you specify the Theme you also have to specify ClassKey. Otherwise TypeScript will fallback to the default which is string.
@eps1lon I think you misunderstood. I want to pass props to useStyles that are used inside the stylesheet. I want to type these. But it doesn't seem to be possible to type these without having to define them manually.
But it doesn't seem to be possible to type these without having to define them manually.
makeStyles<Theme, ClassKey, Props> if you prefer this syntax. You have to decide though in TypeScript. Either use inference or type each generic argument. There is no middleground in TypeScript. If you're interested in this feature please subscribe to microsoft/TypeScript#26242
It's not possible to type props of
createStyles
ormakeStyles
while still inferring the class names.Current Behavior 😯
Using
makeStyles<Theme, SomeProps>
will result inRecord<string, string>
as it's return-value.I don't have to even try
createStyles
since the class names come as the first generic type and are not optional.Expected Behavior 🤔
To be able to type props of
makeStyles
orcreateStyles
without loosing inference of the class names.Steps to Reproduce 🕹
https://codesandbox.io/s/elated-river-kzgm5
Your Environment 🌎
The text was updated successfully, but these errors were encountered: