fix(makeStyles): make props mandatory when declared non-empty#3859
Open
darkbasic wants to merge 1 commit intoreact-native-elements:nextfrom
Open
fix(makeStyles): make props mandatory when declared non-empty#3859darkbasic wants to merge 1 commit intoreact-native-elements:nextfrom
darkbasic wants to merge 1 commit intoreact-native-elements:nextfrom
Conversation
Contributor
Author
|
Please note that the build is currently broken in the next branch, see #3858 |
Member
|
Fixed by #3844. Let me know if it's working for the snippets you provided. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Currently
makeStylesalways returns a function which optionally requiresprops.I think this is a typings bug because
propsshould be required if the props are needed to create the styles.With my change if you specify a non empty type for the props the argument of the returned function would be required, otherwise optional.
Since
MyComponentStylePropsis an empty objectpropswould not be required.If you don't specify a type
propswouldn't be required either.Now you will have to specify
propsotherwiseuseStyleswill error out.I would have rather preferred to let the user specify the generic (ex.
makeStyles<MyComponentStyleProps>((theme, props)) but that would force you to specify all generics so you won't be able to infer the stylesheet type for the second generic.Once microsoft/TypeScript#54047 gets merged it should be possible to do so.
Type of change
How Has This Been Tested?
exampleappChecklist
yarn docs-build-apiAdditional context