-
-
Notifications
You must be signed in to change notification settings - Fork 32.8k
[TextField] Fix typescript error when using inputAdornedStart, inputAdornedEnd classes with default variant and standard variant #36863
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,23 +21,17 @@ const filledProps = { | |
|
|
||
| // baseline behavior | ||
| <TextField variant="filled" {...filledProps} />; | ||
| // @ts-expect-error | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed this because didn't understand the reasoning behind expecting typescript error when classes are getting applied. |
||
| <TextField {...filledProps} />; // desired to throw | ||
|
|
||
| // styled | ||
| { | ||
| const StyledTextField = styled(TextField)``; | ||
| <StyledTextField variant="filled" {...filledProps} />; // desired to pass | ||
| // @ts-expect-error | ||
| <StyledTextField {...filledProps} />; // undesired, should throw | ||
| } | ||
|
|
||
| // @emotion/styled | ||
| { | ||
| const StyledTextField = emotionStyled(TextField)``; | ||
| <StyledTextField variant="filled" {...filledProps} />; | ||
| // @ts-expect-error | ||
| <StyledTextField {...filledProps} />; // desired to throw | ||
| } | ||
|
|
||
| // https://github.com/mui/material-ui/issues/14586 | ||
|
|
||
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.
If I remove both of these classes, it throws an error in outlined variant textfield, when the
variant="outlined"is not explicitly provided to the Text Field component.Also, these classes are for the standard text field. Not sure why it throws type error for an implicit outlined text field if I remove them. If you can find out the reason it would be great.
Uh oh!
There was an error while loading. Please reload this page.
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.
@ZeeshanTamboli when
variant="outlined"isnotapplied, in component implementaion code, default component is set toOutlinedInputhere. buttypesind.tsfile doesn't know that if variant is not provided it should applyOutlinedTextFieldPropstoTextFieldProps.code reference: https://github.com/mui/material-ui/blob/master/packages/mui-material/src/TextField/TextField.d.ts#L229
Although this will be fixed in this PR #36737
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.
If the type is going to be fixed in #36737 where TypeScript will be able to pick
OutlinedTextFieldPropsfor implicit outlined variant, then I think you can include these classes in that PR. There isn't a need to create a separate PR because it is related to the bug you are trying to solve. Here in this PR, in my opinion, it is confusing for implicit outlined text field (i.e variant is not applied). The classes being added here is only for the standard variant, not for outlined text fields.This would help in future if somebody wants to check the related PR. Basically, it should not confuse a future reader. We also don't know when that PR will be merged and released after this.
Uh oh!
There was an error while loading. Please reload this page.
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.
@ZeeshanTamboli okay, i've moved changes to #36737 , can you review that PR. I will close this PR, once #36737 is merged