Skip to content
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

[material-ui] Change React.ReactElement<any> to React.ReactElement<unknown> #43402

Merged
merged 20 commits into from
Oct 3, 2024
2 changes: 1 addition & 1 deletion docs/data/material/components/app-bar/BackToTop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Props {
* You won't need it on your project.
*/
window?: () => Window;
children?: React.ReactElement<any>;
children?: React.ReactElement<unknown>;
}

function ScrollTop(props: Props) {
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/app-bar/ElevateAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Props {
* You won't need it on your project.
*/
window?: () => Window;
children?: React.ReactElement<any>;
children?: React.ReactElement<{ elevation?: number }>;
}

function ElevationScroll(props: Props) {
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/app-bar/HideAppBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface Props {
* You won't need it on your project.
*/
window?: () => Window;
children?: React.ReactElement<any>;
children?: React.ReactElement<unknown>;
}

function HideOnScroll(props: Props) {
Expand Down
12 changes: 8 additions & 4 deletions docs/data/material/components/autocomplete/Virtualize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,13 @@ const ListboxComponent = React.forwardRef<
React.HTMLAttributes<HTMLElement>
>(function ListboxComponent(props, ref) {
const { children, ...other } = props;
const itemData: React.ReactElement<any>[] = [];
(children as React.ReactElement<any>[]).forEach(
(item: React.ReactElement<any> & { children?: React.ReactElement<any>[] }) => {
const itemData: React.ReactElement<unknown>[] = [];
(children as React.ReactElement<unknown>[]).forEach(
(
item: React.ReactElement<unknown> & {
children?: React.ReactElement<unknown>[];
},
) => {
itemData.push(item);
itemData.push(...(item.children || []));
},
Expand All @@ -73,7 +77,7 @@ const ListboxComponent = React.forwardRef<
const itemCount = itemData.length;
const itemSize = smUp ? 36 : 48;

const getChildSize = (child: React.ReactElement<any>) => {
const getChildSize = (child: React.ReactElement<unknown>) => {
if (child.hasOwnProperty('group')) {
return 48;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/dialogs/FullScreenDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { TransitionProps } from '@mui/material/transitions';

const Transition = React.forwardRef(function Transition(
props: TransitionProps & {
children: React.ReactElement<any>;
children: React.ReactElement<unknown>;
},
ref: React.Ref<unknown>,
) {
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/lists/InteractiveList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import Typography from '@mui/material/Typography';
import FolderIcon from '@mui/icons-material/Folder';
import DeleteIcon from '@mui/icons-material/Delete';

function generate(element: React.ReactElement<any>) {
function generate(element: React.ReactElement<unknown>) {
return [0, 1, 2].map((value) =>
React.cloneElement(element, {
key: value,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/popper/SpringPopper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Popper from '@mui/material/Popper';
import { useSpring, animated } from '@react-spring/web';

interface FadeProps {
children?: React.ReactElement<any>;
children?: React.ReactElement<unknown>;
in?: boolean;
onEnter?: () => void;
onExited?: () => void;
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/components/rating/RadioGroupRating.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const StyledRating = styled(Rating)(({ theme }) => ({

const customIcons: {
[index: string]: {
icon: React.ReactElement<any>;
icon: React.ReactElement<unknown>;
label: string;
};
} = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const ColorlibStepIconRoot = styled('div')<{
function ColorlibStepIcon(props: StepIconProps) {
const { active, completed, className } = props;

const icons: { [index: string]: React.ReactElement<any> } = {
const icons: { [index: string]: React.ReactElement<unknown> } = {
1: <SettingsIcon />,
2: <GroupAddIcon />,
3: <VideoLabelIcon />,
Expand Down
2 changes: 1 addition & 1 deletion docs/data/material/integrations/routing/ListRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function Router(props: { children?: React.ReactNode }) {
}

interface ListItemLinkProps {
icon?: React.ReactElement<any>;
icon?: React.ReactElement<unknown>;
primary: string;
to: string;
}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/about/HowToSupport.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function Widget({
}: {
children: React.ReactNode;
title: string;
icon: React.ReactElement<any>;
icon: React.ReactElement<unknown>;
}) {
return (
<Paper
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/header/HeaderNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const PRODUCT_IDS = [
];

type ProductSubMenuProps = {
icon: React.ReactElement<any>;
icon: React.ReactElement<unknown>;
name: React.ReactNode;
description: React.ReactNode;
chip?: React.ReactNode;
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/home/MaterialDesignComponents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function Demo({
}: {
name: string;
theme: Theme | undefined;
children: React.ReactElement<any>;
children: React.ReactElement<unknown>;
control?: { prop: string; values: Array<string>; defaultValue?: string };
}) {
const [propValue, setPropValue] = React.useState(
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/home/UserFeedbacks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ function Feedback({
avatarSrcSet: string;
name: string;
role: string;
company?: React.ReactElement<any>;
company?: React.ReactElement<unknown>;
};
}) {
return (
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/pricing/PricingTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ function RowHead({
children,
startIcon,
...props
}: BoxProps & { startIcon?: React.ReactElement<any> }) {
}: BoxProps & { startIcon?: React.ReactElement<unknown> }) {
return (
<Box
{...props}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/productX/XRoadmap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function RoadmapStatusDot({ color }: RoadmapStatusDotProps) {
}

export default function XRoadmap() {
function renderList(content: React.ReactElement<any>, nested?: boolean) {
function renderList(content: React.ReactElement<unknown>, nested?: boolean) {
return (
<Box
sx={{
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/showcase/ViewToggleButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const views = ['quilt', 'module', 'agenda', 'week', 'sidebar'] as const;

type View = (typeof views)[number];

const viewIcons: Record<View, React.ReactElement<any>> = {
const viewIcons: Record<View, React.ReactElement<unknown>> = {
quilt: <ViewQuiltRounded />,
module: <ViewModuleRounded />,
agenda: <ViewAgendaRounded />,
Expand Down
2 changes: 1 addition & 1 deletion docs/src/components/typography/SectionHeadline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface SectionHeadlineProps {
*/
inverted?: boolean;
overline?: React.ReactNode;
title: string | React.ReactElement<any>;
title: string | React.ReactElement<React.HTMLAttributes<HTMLElement>>;
}

export default function SectionHeadline(props: SectionHeadlineProps) {
Expand Down
4 changes: 2 additions & 2 deletions docs/src/layouts/HeroContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import { alpha } from '@mui/material/styles';
interface HeroContainerProps {
disableMobileHidden?: boolean;
disableTabExclusion?: boolean;
left: React.ReactElement<any>;
left: React.ReactElement<unknown>;
linearGradient?: boolean;
right: React.ReactElement<any>;
right: React.ReactElement<unknown>;
rightSx?: BoxProps['sx'];
}

Expand Down
2 changes: 1 addition & 1 deletion docs/src/modules/components/JoyUsageDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ interface JoyUsageDemoProps<ComponentProps> {
* A function to override the code block result.
*/
getCodeBlock?: (code: string, props: ComponentProps) => string;
renderDemo: (props: ComponentProps) => React.ReactElement<any>;
renderDemo: (props: ComponentProps) => React.ReactElement<unknown>;
}

export default function JoyUsageDemo<T extends { [k: string]: any } = {}>({
Expand Down
4 changes: 2 additions & 2 deletions docs/src/modules/components/JoyVariablesDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function formatSx(sx: { [k: string]: string | number }) {
interface SlotVariablesProps {
slot: string;
data: Array<DataItem>;
renderField: (item: DataItem) => React.ReactElement<any>;
renderField: (item: DataItem) => React.ReactElement<unknown>;
defaultOpen?: boolean;
}

Expand Down Expand Up @@ -83,7 +83,7 @@ export default function JoyVariablesDemo(props: {
componentName: string;
childrenAccepted?: boolean;
data: Array<DataItem | [string, Array<DataItem>, { defaultOpen?: boolean } | undefined]>;
renderDemo: (sx: { [k: string]: string | number }) => React.ReactElement<any>;
renderDemo: (sx: { [k: string]: string | number }) => React.ReactElement<unknown>;
renderCode?: (formattedSx: string) => string;
}) {
const { componentName, data = [], childrenAccepted = false, renderCode } = props;
Expand Down
2 changes: 1 addition & 1 deletion docs/types/docs.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ declare module 'docs/src/modules/components/HighlightedCode' {
component?: React.ElementType;
sx?: object;
}
export default function HighlightedCode(props: Props): React.ReactElement<any>;
export default function HighlightedCode(props: Props): React.ReactElement<unknown>;
}

declare module 'react-imask';
16 changes: 10 additions & 6 deletions packages-internal/test-utils/src/createRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,12 @@ export interface MuiRenderToStringResult {
hydrate(): MuiRenderResult;
}

interface DataAttributes {
[key: `data-${string}`]: string;
}

function render(
element: React.ReactElement<any>,
element: React.ReactElement<DataAttributes>,
configuration: ClientRenderConfiguration,
): MuiRenderResult {
const { container, hydrate, wrapper } = configuration;
Expand Down Expand Up @@ -322,7 +326,7 @@ function render(
}

function renderToString(
element: React.ReactElement<any>,
element: React.ReactElement<DataAttributes>,
configuration: ServerRenderConfiguration,
): { container: HTMLElement; hydrate(): MuiRenderResult } {
const { container, wrapper: Wrapper } = configuration;
Expand Down Expand Up @@ -449,9 +453,9 @@ function createClock(

export interface Renderer {
clock: Clock;
render(element: React.ReactElement<any>, options?: RenderOptions): MuiRenderResult;
render(element: React.ReactElement<DataAttributes>, options?: RenderOptions): MuiRenderResult;
renderToString(
element: React.ReactElement<any>,
element: React.ReactElement<DataAttributes>,
options?: RenderOptions,
): MuiRenderToStringResult;
}
Expand Down Expand Up @@ -593,7 +597,7 @@ export function createRenderer(globalOptions: CreateRendererOptions = {}): Rende

return {
clock,
render(element: React.ReactElement<any>, options: RenderOptions = {}) {
render(element: React.ReactElement<DataAttributes>, options: RenderOptions = {}) {
if (!prepared) {
throw new Error(
'Unable to finish setup before `render()` was called. ' +
Expand All @@ -608,7 +612,7 @@ export function createRenderer(globalOptions: CreateRendererOptions = {}): Rende
wrapper: createWrapper(options),
});
},
renderToString(element: React.ReactElement<any>, options: RenderOptions = {}) {
renderToString(element: React.ReactElement<DataAttributes>, options: RenderOptions = {}) {
if (!prepared) {
throw new Error(
'Unable to finish setup before `render()` was called. ' +
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-lab/test/describeConformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { ThemeProvider, createTheme } from '@mui/material/styles';

export default function describeConformance(
minimalElement: React.ReactElement<any>,
minimalElement: React.ReactElement<unknown>,
getOptions: () => ConformanceOptions,
) {
function getOptionsWithDefaults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export function createGetInitialProps(plugins: Plugin[]) {
}

export interface DocumentHeadTagsProps {
emotionStyleTags: React.ReactElement<any>[];
emotionStyleTags: React.ReactElement<unknown>[];
}

export function DocumentHeadTags(props: DocumentHeadTagsProps) {
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/src/Popper/Popper.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { Instance } from '@popperjs/core';
import Tooltip from '@mui/material/Tooltip';

interface Props {
children: React.ReactElement<any>;
children: React.ReactElement<unknown>;
value: number;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/mui-material/test/describeConformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { ThemeProvider, createTheme } from '@mui/material/styles';

export default function describeConformance(
minimalElement: React.ReactElement<any>,
minimalElement: React.ReactElement<unknown>,
getOptions: () => ConformanceOptions,
) {
function getOptionsWithDefaults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export interface GlobalStylesProps<Theme extends object = {}> {

export default function Global<Theme extends object = {}>(
props: GlobalStylesProps<Theme>,
): React.ReactElement<any>;
): React.JSX.Element;
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface GlobalStylesProps {
styles: SCGlobalStylesProps<Theme>['styles'];
}

function GlobalStyles(props: GlobalStylesProps): React.ReactElement<any> {
function GlobalStyles(props: GlobalStylesProps): React.JSX.Element {
return <SCGlobalStyles {...props} defaultTheme={defaultTheme} />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export interface GlobalStylesProps<Theme = {}> {

export default function GlobalStyles<Theme = {}>(
props: GlobalStylesProps<Theme>,
): React.ReactElement<any>;
): React.JSX.Element;
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface GlobalStylesProps {
styles: EmGlobalStylesProps<Theme>['styles'];
}

function GlobalStyles(props: GlobalStylesProps): React.ReactElement<any> {
function GlobalStyles(props: GlobalStylesProps): React.JSX.Element {
return <EmGlobalStyles {...props} defaultTheme={defaultTheme} />;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/mui-system/src/Stack/createStack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function useThemePropsDefault<T extends {}>(props: T) {
* > joinChildren([1,2,3], 0)
* [1,0,2,0,3]
*/
function joinChildren(children: React.ReactNode, separator: React.ReactElement<any>) {
function joinChildren(children: React.ReactNode, separator: React.ReactElement<unknown>) {
const childrenArray = React.Children.toArray(children).filter(Boolean);

return childrenArray.reduce<React.ReactNode[]>((output, child, index) => {
Expand Down Expand Up @@ -209,7 +209,7 @@ export default function createStack(
className={clsx(classes.root, className)}
{...other}
>
{divider ? joinChildren(children, divider as React.ReactElement<any>) : children}
{divider ? joinChildren(children, divider as React.ReactElement<unknown>) : children}
</StackRoot>
);
}) as OverridableComponent<StackTypeMap>;
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-system/src/cssVars/createCssVarsProvider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export interface CreateCssVarsProviderResult<
disableStyleSheetGeneration?: boolean;
}
>,
) => React.ReactElement<any>;
) => React.JSX.Element;
useColorScheme: () => ColorSchemeContextValue<ColorScheme>;
getInitColorSchemeScript: typeof InitColorSchemeScript;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-system/test/describeConformance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
import { ThemeProvider, createTheme } from '@mui/system';

export default function describeConformance(
minimalElement: React.ReactElement<any>,
minimalElement: React.ReactElement<unknown>,
getOptions: () => ConformanceOptions,
) {
function getOptionsWithDefaults() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ import * as React from 'react';
export default function getValidReactChildren(children: React.ReactNode) {
return React.Children.toArray(children).filter((child) =>
React.isValidElement(child),
) as React.ReactElement<any>[];
) as React.ReactElement<unknown>[];
}