import * as React from 'react';
import CardHeader, { CardHeaderProps, CardHeaderTypeMap } from '@mui/material/CardHeader';
const CustomComponent: React.FC<{ stringProp: string; numberProp: number }> =
function CustomComponent() {
return
;
};
type DefaultComponent = CardHeaderTypeMap['defaultComponent'];
interface ComponentProp {
component?: React.ElementType;
}
function createElementBasePropMixedTest() {
React.createElement>(CardHeader);
React.createElement>(CardHeader, {
component: 'div',
});
// ExpectError: type system should be demanding the required props of "CustomComponent"
React.createElement>(CardHeader, {
component: CustomComponent,
});
// @ts-expect-error
React.createElement>(CardHeader, {
// This test shouldn't fail but does; stringProp & numberProp are required props of CustomComponent
component: CustomComponent,
stringProp: '',
numberProp: 0,
});
React.createElement(CardHeader, {
disableTypography: true,
});
// @ts-expect-error
React.createElement>(CardHeader, {
unknownProp: 'shouldNotWork',
});
// @ts-expect-error
React.createElement(CardHeader, {
disableTypography: 'hello',
});
// @ts-expect-error
React.createElement(CardHeader, {
disableTypography: 1,
});
// @ts-expect-error
React.createElement>(CardHeader, {
component: 'incorrectElement',
});
}
function createElementTypographyTest() {
React.createElement(CardHeader, {
titleTypographyProps: {
align: 'center',
},
});
// @ts-expect-error
React.createElement(CardHeader, {
titleTypographyProps: {
align: 'incorrectAlign',
},
});
React.createElement(CardHeader, {
titleTypographyProps: {
variant: 'body1',
},
});
// @ts-expect-error
React.createElement(CardHeader, {
titleTypographyProps: {
variant: 123,
},
});
React.createElement>(CardHeader, {
titleTypographyProps: {
component: 'div',
},
});
// ExpectError: This is expected to err; the type system should catch required props from "CustomComponent".
React.createElement>(CardHeader, {
titleTypographyProps: {
component: CustomComponent,
},
});
React.createElement>(CardHeader, {
titleTypographyProps: {
component: CustomComponent,
stringProp: '',
numberProp: 0,
},
});
// ExpectError: This is expected to err; the type system should catch the props type mismatch
// from "CustomComponent" props.
React.createElement>(CardHeader, {
titleTypographyProps: {
component: CustomComponent,
stringProp: 0,
numberProp: '',
},
});
// ExpectError: This is expected to err; the type system is welcoming unknown props.
React.createElement>(CardHeader, {
titleTypographyProps: {
unknownProp: 'shouldNotWork',
},
});
// @ts-expect-error
React.createElement>(CardHeader, {
titleTypographyProps: {
component: 'incorrectComponent',
},
});
// @ts-expect-error
React.createElement(CardHeader, {
titleTypographyProps: true,
});
}
function componentPropTest() {
;
;
// @ts-expect-error
;
// @ts-expect-error
;
}
function mixedCardHeaderComponentAndTypographyTest() {
;
;
;
;
// @ts-expect-error
;
// @ts-expect-error
;
;
// @ts-expect-error
;
;
}
function titleTypographyPropsTest() {
// @ts-expect-error
;
;
;
;
;
;
// @ts-expect-error
;
// @ts-expect-error
;
;
// Regression test for https://github.com/mui/material-ui/issues/21583
// which was probably fixed in https://github.com/mui/material-ui/pull/21552.
Contemplative Reptile}
titleTypographyProps={{ component: 'h2' }}
/>;
}
function subheaderTypographyPropsTest() {
;
;
;
;
;
;
// @ts-expect-error
;
// @ts-expect-error
;
}
function mixedTypographyPropsTest() {
;
;
// @ts-expect-error
;
;
// @ts-expect-error
;
;
;
}