-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
[core] Adds component
prop to OverrideProps
type
#35924
Merged
Merged
Changes from 10 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
7ee5a79
Adds component type to OverrideProps
sai6855 84f20ef
lint
sai6855 ded3b69
added more tests
sai6855 cd3fe83
asterisks in jsdoc must be aligned fix
sai6855 7bdc63d
asterisks in jsdoc must be aligned fix
sai6855 5fd2db9
Added tests for #29942
sai6855 b3e74a7
adds tests for #29191
sai6855 218a625
prettier
sai6855 e336e75
omit component type
sai6855 d9c6442
type fix
sai6855 132e413
add space
sai6855 b6d05a2
Merge branch 'master' into component-type
sai6855 089f989
remove unknown type
sai6855 56e87c2
Merge branch 'master' into component-type
sai6855 28e7cf1
Merge branch 'master' into component-type
sai6855 542f9af
Merge branch 'master' into component-type
sai6855 bc79535
Merge branch 'master' into component-type
sai6855 8703c31
Merge branch 'master' into component-type
sai6855 a584afb
remove component from LinkBaseProps
sai6855 84ecfff
removed casting
sai6855 469e451
fix imports
sai6855 aa249d4
remove casting in routing.md
sai6855 d106afb
rename to PaperOwnProps
sai6855 9a6533b
remove instances of paperbaseprops
sai6855 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import * as React from 'react'; | ||
import Card from '@mui/material/Card'; | ||
import { expectType } from '@mui/types'; | ||
|
||
const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> = | ||
function CustomComponent() { | ||
return <div />; | ||
}; | ||
|
||
function CardTest() { | ||
return ( | ||
<div> | ||
<Card /> | ||
<Card elevation={4} /> | ||
<Card | ||
onClick={(event) => { | ||
expectType<React.MouseEvent<HTMLDivElement, MouseEvent>, typeof event>(event); | ||
}} | ||
/> | ||
<Card | ||
component="a" | ||
href="test" | ||
onClick={(event) => { | ||
expectType<React.MouseEvent<HTMLAnchorElement, MouseEvent>, typeof event>(event); | ||
}} | ||
/> | ||
|
||
<Card component={CustomComponent} stringProp="test" numberProp={0} /> | ||
{/* @ts-expect-error missing stringProp and numberProp */} | ||
<Card component={CustomComponent} /> | ||
</div> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
import * as React from 'react'; | ||
import { Dialog } from '@mui/material'; | ||
import { Dialog, PaperProps } from '@mui/material'; | ||
ZeeshanTamboli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { expectType } from '@mui/types'; | ||
|
||
function optionalChildrenTest() { | ||
<Dialog open />; | ||
const paperProps: PaperProps<'span'> = { | ||
component: 'span', | ||
onClick: (event) => { | ||
expectType<React.MouseEvent<HTMLSpanElement, MouseEvent>, typeof event>(event); | ||
}, | ||
}; | ||
function Test() { | ||
return ( | ||
<React.Fragment> | ||
<Dialog open />; | ||
<Dialog open PaperProps={paperProps} />; | ||
</React.Fragment> | ||
); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as React from 'react'; | ||
import { Drawer, PaperProps } from '@mui/material'; | ||
ZeeshanTamboli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
import { expectType } from '@mui/types'; | ||
|
||
const paperProps: PaperProps<'span'> = { | ||
component: 'span', | ||
onClick: (event) => { | ||
expectType<React.MouseEvent<HTMLSpanElement, MouseEvent>, typeof event>(event); | ||
}, | ||
}; | ||
function Test() { | ||
return ( | ||
<React.Fragment> | ||
<Drawer open />; | ||
<Drawer open PaperProps={paperProps} />; | ||
</React.Fragment> | ||
); | ||
} |
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
66 changes: 66 additions & 0 deletions
66
packages/mui-material/src/FormHelperText/FormHelperText.spec.tsx
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import * as React from 'react'; | ||
import FormHelperText, { FormHelperTextProps } from '@mui/material/FormHelperText'; | ||
import { expectType } from '@mui/types'; | ||
|
||
const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> = | ||
function CustomComponent() { | ||
return <div />; | ||
}; | ||
|
||
const props: FormHelperTextProps<'div'> = { | ||
component: 'div', | ||
onChange: (event) => { | ||
expectType<React.FormEvent<HTMLDivElement>, typeof event>(event); | ||
}, | ||
}; | ||
|
||
const props2: FormHelperTextProps = { | ||
onChange: (event) => { | ||
expectType<React.FormEvent<HTMLParagraphElement>, typeof event>(event); | ||
}, | ||
}; | ||
|
||
const props3: FormHelperTextProps<'span'> = { | ||
// @ts-expect-error | ||
component: 'div', | ||
}; | ||
|
||
const props4: FormHelperTextProps<typeof CustomComponent> = { | ||
component: CustomComponent, | ||
stringProp: '2', | ||
numberProp: 2, | ||
}; | ||
|
||
const props5: FormHelperTextProps<typeof CustomComponent> = { | ||
component: CustomComponent, | ||
stringProp: '2', | ||
numberProp: 2, | ||
// @ts-expect-error | ||
inCorrectProp: 3, | ||
}; | ||
|
||
// @ts-expect-error | ||
const props6: FormHelperTextProps<typeof CustomComponent> = { | ||
component: CustomComponent, | ||
}; | ||
|
||
const TestComponent = () => { | ||
return ( | ||
<React.Fragment> | ||
<FormHelperText /> | ||
<FormHelperText component={'a'} href="/test" /> | ||
|
||
<FormHelperText component={CustomComponent} stringProp="s" numberProp={1} /> | ||
{ | ||
// @ts-expect-error | ||
<FormHelperText component={CustomComponent} /> | ||
} | ||
<FormHelperText | ||
component="span" | ||
onChange={(event) => { | ||
expectType<React.FormEvent<HTMLSpanElement>, typeof event>(event); | ||
}} | ||
/> | ||
</React.Fragment> | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,68 @@ | ||
import * as React from 'react'; | ||
import Paper from '@mui/material/Paper'; | ||
import Grid from '@mui/material/Grid'; | ||
import Grid, { GridProps } from '@mui/material/Grid'; | ||
import { expectType } from '@mui/types'; | ||
|
||
const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> = | ||
function CustomComponent() { | ||
return <div />; | ||
}; | ||
|
||
const props: GridProps<'span'> = { | ||
component: 'span', | ||
onChange: (event) => { | ||
expectType<React.FormEvent<HTMLSpanElement>, typeof event>(event); | ||
}, | ||
}; | ||
|
||
const props2: GridProps = { | ||
onChange: (event) => { | ||
expectType<React.FormEvent<HTMLDivElement>, typeof event>(event); | ||
}, | ||
}; | ||
|
||
const props3: GridProps<'span'> = { | ||
// @ts-expect-error | ||
component: 'div', | ||
}; | ||
|
||
const props4: GridProps<typeof CustomComponent> = { | ||
component: CustomComponent, | ||
stringProp: '2', | ||
numberProp: 2, | ||
}; | ||
|
||
const props5: GridProps<typeof CustomComponent> = { | ||
component: CustomComponent, | ||
stringProp: '2', | ||
numberProp: 2, | ||
// @ts-expect-error | ||
inCorrectProp: 3, | ||
}; | ||
|
||
// @ts-expect-error | ||
const props6: GridProps<typeof CustomComponent> = { | ||
component: CustomComponent, | ||
}; | ||
|
||
function ResponsiveTest() { | ||
<Grid item xs={12} sm={8} md={5} component={Paper} elevation={6} square />; | ||
return ( | ||
<React.Fragment> | ||
<Grid item xs={12} sm={8} md={5} component={Paper} elevation={6} square /> | ||
<Grid item component={'a'} href="/test" /> | ||
|
||
<Grid item component={CustomComponent} stringProp="s" numberProp={1} /> | ||
{ | ||
// @ts-expect-error | ||
<Grid item component={CustomComponent} /> | ||
} | ||
<Grid | ||
item | ||
component="span" | ||
onChange={(event) => { | ||
expectType<React.FormEvent<HTMLSpanElement>, typeof event>(event); | ||
}} | ||
/> | ||
</React.Fragment> | ||
); | ||
} |
Oops, something went wrong.
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 is unfortunate. We shouldn't recommend such hacks, ideally, but I understand where it's coming from. Could ou try to work around it so such an ugly cast is not necessary?
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 tried to remove
as unknown
type without disturbing other files but couldn't able to do it. So instead of fixing casting problem, tried to fix (commit 089f989 ) the root problem which lies in this file .If you are fine with converting
props
inprops.d.ts
file togeneric
, i'll convert all components to generic where applicable. if not i'd appreciate your help fixing the casting issue.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'd ask @mnajdova about the generic, as she's overseeing the styles. To me, it feels OK, but I have less context about the usage of these types.