[typescript] `withStyles()` complains unless using `as`
See original GitHub issue- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior
No type errors should be reported for adding legal styles kv pairs in withStyles()
Current Behavior
For some style
properties, like position
, overflow
, etc, specifying a valid value, e.g., position: 'absolute'
or overflow: 'auto'
reports type errors.
Example:
The only hack is to use as
:
Your Environment
Tech | Version |
---|---|
Material-UI | beta.41 |
React | 16.2.0 |
etc |
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:17 (14 by maintainers)
Top Results From Across the Web
[typescript] withStyles() complains unless using as #10995
I have searched the issues of this repository and believe that this is not a duplicate. Expected Behavior No type errors should be...
Read more >Typescript Material UI Property 'classes' is missing in type for ...
But you have export your component using export default withStyles(styles)(YourComponent) because otherwise TypeScript will still complain ...
Read more >TypeScript React with Material-ui's makeStyles/withStyles ...
I don't see why classes should even have a delta property, unless material ui adds the property from the hook to the parent,...
Read more >TypeScript - Yakov Fain
If you run the app with the browser console open, you'll see the message “useEffect() was invoked” each time when you enter a...
Read more >TypeScript - Material-UI
Unfortunately due to a current limitation of TypeScript decorators, withStyles(styles) can't be used as a decorator in TypeScript. Customization of Theme. When ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This should be resolved by #11609, take a look at the updated TypeScript guide there and feel free to comment.
This is a result of the recent updates to
@types/jss
, at https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jss.AFAICT, no one’s raised an issue on it there yet; someone from mui definitely should!
They (the folks working on the jss type defs) are doing some very radical changes without a good rollout process, imho. It’s not clear to me what a better process would be, though; maybe someone else has a thought.
(I’m not a mui project member or anything, I’m just sharing what I know/think.)