@@ -5,6 +5,7 @@ import { render, screen } from '@testing-library/react';
55import { useFetcher } from 'react-router' ;
66import { RemixFormProvider , useRemixForm } from 'remix-hook-form' ;
77import { z } from 'zod' ;
8+ import type { ElementType , PropsWithChildren } from 'react' ;
89
910// Mock useFetcher
1011jest . mock ( 'react-router' , ( ) => ( {
@@ -30,14 +31,14 @@ const TestFormWithError = ({
3031} : {
3132 initialErrors ?: Record < string , { message : string } > ;
3233 formErrorName ?: string ;
33- customComponents ?: any ;
34+ customComponents ?: { FormMessage ?: React . ComponentType < PropsWithChildren < Record < string , unknown > > > } ;
3435 className ?: string ;
3536} ) => {
3637 const mockFetcher = {
3738 data : { errors : initialErrors } ,
3839 state : 'idle' as const ,
3940 submit : jest . fn ( ) ,
40- Form : 'form' as any ,
41+ Form : 'form' as ElementType ,
4142 } ;
4243
4344 mockUseFetcher . mockReturnValue ( mockFetcher ) ;
@@ -142,7 +143,7 @@ describe('FormError Component', () => {
142143
143144 describe ( 'Component Customization' , ( ) => {
144145 it ( 'uses custom FormMessage component when provided' , ( ) => {
145- const CustomFormMessage = ( { children, ...props } : any ) => (
146+ const CustomFormMessage = ( { children, ...props } : PropsWithChildren < Record < string , unknown > > ) => (
146147 < div data-testid = "custom-form-message" className = "custom-message" { ...props } >
147148 Custom: { children }
148149 </ div >
@@ -216,7 +217,7 @@ describe('FormError Component', () => {
216217 } ,
217218 state : 'idle' as const ,
218219 submit : jest . fn ( ) ,
219- Form : 'form' as any ,
220+ Form : 'form' as ElementType ,
220221 } ;
221222
222223 mockUseFetcher . mockReturnValue ( mockFetcher ) ;
@@ -314,7 +315,7 @@ describe('FormError Component', () => {
314315 it ( 'does not re-render unnecessarily when unrelated form state changes' , ( ) => {
315316 const renderSpy = jest . fn ( ) ;
316317
317- const CustomFormMessage = ( { children, ...props } : any ) => {
318+ const CustomFormMessage = ( { children, ...props } : PropsWithChildren < Record < string , unknown > > ) => {
318319 renderSpy ( ) ;
319320 return < div { ...props } > { children } </ div > ;
320321 } ;
@@ -344,7 +345,7 @@ describe('FormError Integration Tests', () => {
344345 data : null ,
345346 state : 'idle' as const ,
346347 submit : jest . fn ( ) ,
347- Form : 'form' as any ,
348+ Form : 'form' as ElementType ,
348349 } ;
349350
350351 mockUseFetcher . mockReturnValue ( mockFetcher ) ;
0 commit comments