Closed Zaid-Ajaj closed 4 years ago
Unfortunately that won't work.
If I have only the unit
overload as a proper type member and the rest as extension members, it will resolve to the unit
overload, but then it's fixed and later usage can't change it to non-unit
.
If I have both the unit
and the generic 'props
overload as proper type members, overload resolution fails.
Further tips are welcome!
I think my previous comment was mistaken. I seem to have thought this was an overload resolution error. The actual compiler error is a value restriction error, because useStyles
is a generic value whose type can't be inferred unless it's used somewhere.
There are two simple solutions/workarounds:
useStyles
hook in a component, as originally mentionedlet useStyles: MyProps -> _ = Styles.makeStyles ...
This has been mentioned in the makeStyles
docs. Since the problem is only temporary and it's easy to workaround, as well as in lieu of better solutions, I'm closing this.
The following doesn't compile
unless it is actually used, I was trying to fix the compile error when I was defining the value but the workflow is that I use it somewhere and the compile error would go away. I guess it is OK but this is sub optimal UX. Would there be a way to make add an overload that by default returns a function that takes a unit instead?