diff --git a/packages/mui-utils/src/getReactNodeRef/getReactNodeRef.ts b/packages/mui-utils/src/getReactNodeRef/getReactNodeRef.ts index e4cfe22c2a9ee3..2e1a49683b70c7 100644 --- a/packages/mui-utils/src/getReactNodeRef/getReactNodeRef.ts +++ b/packages/mui-utils/src/getReactNodeRef/getReactNodeRef.ts @@ -9,8 +9,8 @@ import * as React from 'react'; */ export default function getReactNodeRef(element: React.ReactNode): React.Ref | null { // 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions - return (element as any)!.props.propertyIsEnumerable('ref') - ? (element as any)!.props.ref + return (element as any).props.propertyIsEnumerable('ref') + ? (element as any).props.ref : // @ts-expect-error element.ref is not included in the ReactElement type // We cannot check for it, but isValidElement is true at this point // https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189