import { NOOP } from '@vue/shared' import type { SFCWithInstall } from './typescript' export const withInstall = >( main: T, extra?: E ) => { ;(main as SFCWithInstall).install = (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 } export const withInstallFunction = (fn: T, name: string) => { ;(fn as SFCWithInstall).install = (app) => { app.config.globalProperties[name] = fn } return fn as SFCWithInstall } export const withNoopInstall = (component: T) => { ;(component as SFCWithInstall).install = NOOP return component as SFCWithInstall }