import { InternalError } from "../error" ; import { GenericInstance , isElementImpl } from "../jsx" ; import { currentContext } from "./hooks" ; export interface AnyMethods { [ name ] : ( ... args : any [ ] ) => any ; } export function useImperativeMethods < T extends object = AnyMethods > ( create ) { const ctx = currentContext ( ) ; if ( ! isElementImpl ( ctx . element ) ) throw new InternalError ( `Build context element is not ElementImpl` ) ; Object . assign ( ctx . element . instanceMethods , create ( ) ) ; }