From fa4969e7a3aefa6863203f9294fc5e769ddf6d8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Mon, 11 Dec 2023 22:04:56 +0800 Subject: [PATCH] feat(types): export ObjectPlugin and FunctionPlugin types (#8946) close #8577 --- packages/runtime-core/src/apiCreateApp.ts | 16 +++++++++------- packages/runtime-core/src/index.ts | 2 ++ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/runtime-core/src/apiCreateApp.ts b/packages/runtime-core/src/apiCreateApp.ts index 423c81d7441..8ba9429f447 100644 --- a/packages/runtime-core/src/apiCreateApp.ts +++ b/packages/runtime-core/src/apiCreateApp.ts @@ -149,17 +149,19 @@ export interface AppContext { filters?: Record } -type PluginInstallFunction = Options extends unknown[] +type PluginInstallFunction = Options extends unknown[] ? (app: App, ...options: Options) => any : (app: App, options: Options) => any +export type ObjectPlugin = { + install: PluginInstallFunction +} +export type FunctionPlugin = PluginInstallFunction & + Partial> + export type Plugin = - | (PluginInstallFunction & { - install?: PluginInstallFunction - }) - | { - install: PluginInstallFunction - } + | FunctionPlugin + | ObjectPlugin export function createAppContext(): AppContext { return { diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index ab86bfce7dc..06300cbf68f 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -212,6 +212,8 @@ export type { AppConfig, AppContext, Plugin, + ObjectPlugin, + FunctionPlugin, CreateAppFunction, OptionMergeFunction } from './apiCreateApp'