-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Badge] Fix TS custom variants #24407
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4e2538c
relaxed unstyled variant prop type
mnajdova f28af7b
added module augmentation test
mnajdova bf0a18c
prettier
mnajdova a6e460c
add true negative
eps1lon 36de6e3
fixed regression on the badge
mnajdova b6967d0
prettier
mnajdova File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't seem intended. We now say
Badge
expects anystring
when it only supports'dot' | 'standard'
: https://deploy-preview-24407--material-ui.netlify.app/api/badge/Though it's already not ideal on
next
: https://next--material-ui.netlify.app/api/badge/It should just say
'dot' | 'standard'
, no?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify: The goal of this PR doesn't need to be
'dot' | 'standard'
. Keeping the current one is fine.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can take a look later on whether we can improve the generation of the docs regarding these kind of props.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When is this later going to be? We already made it worse when introducing
string
(#22140). Now we're making it worse again. Follow-ups are ok but it's clear to me that they're not working in this instance.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the expected result in the docs is "string" for the unstyled component. It's meant to not create any constraints when implementing a design spec. For the styled component, it does look like a regression.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation got worse.
Badge#variant
does not support arbitrary strings which the change in #22140 implied.Expected:
Badge#variant
supports'dot' | 'standard'
UnstyledBadge#variant
supportsstring
Actual:
Badge#variant
supportsstring
(was wrong before with'dot' | 'standard' | string
)Only
/api/badge
is problematic. The types seem correct. They still reject an unsupportedvariant
:a6e460c
(#24407)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see now, let me take a look on buildApi and what we have there. I think the string may be coming from the unstyled component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed the issue in the buildAPI, there are no changes to the
/api/badge
now. For not including the| string
part, let's resolve it separately. I think it will require more work, or we will need to whitelist which props should have a custom documentation logic, so we can extract the string option out of those (variant, color, size and all other props for which we want to support custom defined values)