Type pattern for partial classes override
See original GitHub issueWhen using makeStyles with Typescript, it requires all styles as follows:
Argument of type '{ root: { minWidth: number; }; }' is not assignable to parameter of type 'Styles<Theme, {}, ButtonClassKey>'.
Type '{ root: { minWidth: number; }; }' is missing the following properties from type 'Record<ButtonClassKey, CSSProperties | ((props: {}) => CSSProperties)>': label, text, textPrimary, textSecondary, and 12 more.ts(2345)
In my understanding, only the styles I want can be provided.
- This is not a v0.x issue.
- I have searched the issues of this repository and believe that this is not a duplicate.
Expected Behavior 🤔
No type error occurs.
Current Behavior 😯
Type error occurs.
Steps to Reproduce 🕹
Context 🔦
Your Environment 🌎
Tech | Version |
---|---|
Material-UI | 4.0.0-rc.0 |
React | 16.8.6 |
TypeScript | 3.4.5 |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:14 (8 by maintainers)
Top Results From Across the Web
Type pattern for partial classes override · Issue #15777 - GitHub
When using makeStyles with Typescript, it requires all styles as follows: Argument of type '{ root: { minWidth: number; } ...
Read more >Partial Classes and Methods - C# Programming Guide
Partial classes and methods in C# split the definition of a class, a struct, an interface, or a method over two or more...
Read more >How to override a partial class property - Stack Overflow
The partial keyword on a class just means that it can be declared multiple times in the same assembly.
Read more >C# Partial Classes and Methods - TutorialsTeacher
Partial classes or structs can contain a method that split into two separate .cs files of the partial class or struct. One of...
Read more >Partial Class and Partial Methods in C# - Dot Net Tutorials
In this article, I am going to discuss Partial Classes and ... Why we Should Override ToString Method in C# ... Only One...
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 Free
Top 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
Cool! I’ll see if my itch persists and try it out if I get a chance.
@eps1lon so, I’m not really following; @takakobem and I want to do the same thing, of purposefully restricting our styles def to known-good class keys, i.e. your comment here:
Ah, okay, I see, you’re right; FWIW I’m using
createStyles
via thewithStyles
HOC, which doesn’t catch that:Granted, it looks like
withStyles
has someany
s in it and HOC’s in general are a pita to get types right, hence why I wanted/expected to do the enforcement on thecreateStyles
side…I guess also, why not change
createStyles
to take the aPartial
, or is the idea that that would break some of the type inference that is currently happening for theclasses={useStyles()}
usage?If it would, then it makes sense to keep as-is since a majority of use cases do what it inferred. I didn’t realize the
classes={useStyles()}
would catch this.