import type { App } from 'vue' import type { SFCWithInstall } from './types' export const withInstall = >( main: T, extra?: E ) => { ;(main as SFCWithInstall).install = (app: App): void => { for (const comp of [main, ...Object.values(extra ?? {})]) { app.component(comp.name, comp) } } if (extra) { for (const [key, comp] of Object.entries(extra)) { ;(main as any)[key] = comp } } return main as SFCWithInstall & E }