forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
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
13 changed files
with
342 additions
and
10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
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" /> | ||
|
||
<Card component={CustomComponent} stringProp="test" numberProp={0} /> | ||
{/* @ts-expect-error missing stringProp and numberProp */} | ||
<Card<typeof CustomComponent> 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> | ||
); | ||
} |
61 changes: 61 additions & 0 deletions
61
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,61 @@ | ||
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 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,63 @@ | ||
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 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> | ||
); | ||
} |
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,66 @@ | ||
import * as React from 'react'; | ||
import MenuItem, { MenuItemProps } from '@mui/material/MenuItem'; | ||
import { expectType } from '@mui/types'; | ||
|
||
const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> = | ||
function CustomComponent() { | ||
return <div />; | ||
}; | ||
|
||
const props: MenuItemProps<'div'> = { | ||
component: 'div', | ||
onChange: (event) => { | ||
expectType<React.FormEvent<HTMLDivElement>, typeof event>(event); | ||
}, | ||
}; | ||
|
||
const props2: MenuItemProps = { | ||
onChange: (event) => { | ||
expectType<React.FormEvent<HTMLLIElement>, typeof event>(event); | ||
}, | ||
}; | ||
|
||
const props4: MenuItemProps<typeof CustomComponent> = { | ||
component: CustomComponent, | ||
stringProp: '2', | ||
numberProp: 2, | ||
}; | ||
|
||
const props5: MenuItemProps<typeof CustomComponent> = { | ||
component: CustomComponent, | ||
stringProp: '2', | ||
numberProp: 2, | ||
// @ts-expect-error | ||
inCorrectProp: 3, | ||
}; | ||
|
||
// @ts-expect-error | ||
const props6: MenuItemProps<typeof CustomComponent> = { | ||
component: CustomComponent, | ||
}; | ||
|
||
const TestComponent = () => { | ||
return ( | ||
<React.Fragment> | ||
<MenuItem /> | ||
<MenuItem component={'a'} href="/test" /> | ||
|
||
<MenuItem component={CustomComponent} stringProp="s" numberProp={1} /> | ||
{ | ||
// @ts-expect-error | ||
<MenuItem component={CustomComponent} /> | ||
} | ||
<MenuItem | ||
onChange={(event) => { | ||
expectType<React.FormEvent<HTMLLIElement>, typeof event>(event); | ||
}} | ||
/> | ||
<MenuItem | ||
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
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
Oops, something went wrong.