fix: resolve TS18046 errors for React 19 element props type
React 19 types React.ReactElement props as unknown instead of any. Test helper functions that access element.props.children, .className, or .href need explicit props type parameters on React.ReactElement and isValidElement. Changes: - admin/PublicShell.test.ts: add WithChildren type, use React.ReactElement<WithChildren> - dashboard/PublicShell.test.ts: same pattern for childTypes and contentWrapper - dashboard/StatCard.test.ts: add ElementWithClass type for className access - dashboard/public-auth-pages.test.ts: add ElementWithHref type for href access No any, @ts-ignore, or type assertion bypass used.
This commit is contained in:
@@ -6,7 +6,9 @@ vi.mock('@/components/PublicFooter', () => ({ default: function MockAdminFooter(
|
||||
|
||||
import PublicShell from './PublicShell'
|
||||
|
||||
function childTypes(node: React.ReactElement): string[] {
|
||||
type WithChildren = { children?: React.ReactNode }
|
||||
|
||||
function childTypes(node: React.ReactElement<WithChildren>): string[] {
|
||||
return React.Children.toArray(node.props.children).filter(isValidElement).map((child) => {
|
||||
const type = child.type as any
|
||||
if (typeof type === 'string') return type
|
||||
|
||||
Reference in New Issue
Block a user