I was trying to define the type in my component in a different way, I know it can be done using classes but is there a way to achieve this with functional components without exporting the interface? Despite my extensive research, I couldn't find any relevant information on this.
const Elem1 = forwardRef((props : any, ref : { open()? : void }) => {
useImperativeHandle(ref, () => ({
open: () => console.log('opened')
}))
....
})
const Elem2 = () => {
const elem1Ref = useRef<Elem1>()
elem1Ref?.current?.open()
....
}