-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
540 additions
and
129 deletions.
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
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,19 @@ | ||
import * as React from 'react'; | ||
import { Dialog } from '@mui/material'; | ||
import Dialog from '@mui/material/Dialog'; | ||
import { PaperProps } from '@mui/material/Paper'; | ||
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,19 @@ | ||
import * as React from 'react'; | ||
import Drawer from '@mui/material/Drawer'; | ||
import { PaperProps } from '@mui/material/Paper'; | ||
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.