@@ -255,13 +255,26 @@ vi.mock('react-bootstrap', () => {
255255
256256// Separate mock for direct 'react-bootstrap/Alert' import used in Alert component
257257vi . mock ( 'react-bootstrap/Alert' , ( ) => {
258- const { h } = require ( 'preact' ) ;
259- const Alert = ( { children, variant, dismissible, onClose } : { children ?: any ; variant ?: string ; dismissible ?: boolean ; onClose ?: ( ) => void ; } ) =>
258+ interface MockAlertProps {
259+ children ?: ComponentChildren ;
260+ variant ?: string ;
261+ dismissible ?: boolean ;
262+ onClose ?: ( ) => void ;
263+ }
264+
265+ interface AlertComponent {
266+ ( props : MockAlertProps ) : ReturnType < typeof h > ;
267+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
268+ Heading ?: ( props : { children ?: ComponentChildren } ) => any ;
269+ }
270+ // Define without annotation first to prevent TS from narrowing attributes incompatibly
271+ const AlertFn = ( { children, variant, dismissible, onClose } : MockAlertProps ) =>
260272 h ( 'div' , { className : `alert alert-${ variant || 'primary' } ` } , [
261273 children ,
262274 dismissible && h ( 'button' , { 'data-testid' : 'close-alert' , onClick : onClose } , '×' )
263275 ] ) ;
264- ( Alert as any ) . Heading = ( { children } : { children ?: any } ) => h ( 'h4' , { 'data-testid' : 'alert-heading' } , children ) ;
276+ const Alert = AlertFn as AlertComponent ;
277+ Alert . Heading = ( { children } : { children ?: ComponentChildren } ) => h ( 'h4' , { 'data-testid' : 'alert-heading' } , children ) ;
265278 return { default : Alert } ;
266279} ) ;
267280
0 commit comments