const PluginB: Plugin = {
install: (app, arg1, arg2) => app.provide('bar', arg1 + arg2)
}
- const PluginC: any = undefined
+ class PluginC {
+ someProperty = {}
+ static install() {
+ app.provide('baz', 2)
+ }
+ }
+ const PluginD: any = undefined
const app = createApp()
app.use(PluginA)
app.use(PluginB, 1, 1)
+ app.use(PluginC)
const Root = {
setup() {
`Plugin has already been applied to target app`
).toHaveBeenWarnedTimes(1)
- app.use(PluginC)
+ app.use(PluginD)
expect(
`A plugin must either be a function or an object with an "install" ` +
`function.`
type PluginInstallFunction = (app: App, ...options: any[]) => any
export type Plugin =
- | PluginInstallFunction
+ | PluginInstallFunction & { install?: PluginInstallFunction }
| {
install: PluginInstallFunction
}
use(plugin: Plugin, ...options: any[]) {
if (installedPlugins.has(plugin)) {
__DEV__ && warn(`Plugin has already been applied to target app.`)
- } else if (isFunction(plugin)) {
- installedPlugins.add(plugin)
- plugin(app, ...options)
} else if (plugin && isFunction(plugin.install)) {
installedPlugins.add(plugin)
plugin.install(app, ...options)
+ } else if (isFunction(plugin)) {
+ installedPlugins.add(plugin)
+ plugin(app, ...options)
} else if (__DEV__) {
warn(
`A plugin must either be a function or an object with an "install" ` +