From: 三咲智子 Kevin Deng Date: Mon, 11 Dec 2023 14:04:56 +0000 (+0800) Subject: feat(types): export ObjectPlugin and FunctionPlugin types (#8946) X-Git-Tag: v3.4.0-beta.1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa4969e7a3aefa6863203f9294fc5e769ddf6d8f;p=thirdparty%2Fvuejs%2Fcore.git feat(types): export ObjectPlugin and FunctionPlugin types (#8946) close #8577 --- diff --git a/packages/runtime-core/src/apiCreateApp.ts b/packages/runtime-core/src/apiCreateApp.ts index 423c81d744..8ba9429f44 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 ab86bfce7d..06300cbf68 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'