]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(types): export ObjectPlugin and FunctionPlugin types (#8946)
author三咲智子 Kevin Deng <sxzz@sxzz.moe>
Mon, 11 Dec 2023 14:04:56 +0000 (22:04 +0800)
committerGitHub <noreply@github.com>
Mon, 11 Dec 2023 14:04:56 +0000 (22:04 +0800)
close #8577

packages/runtime-core/src/apiCreateApp.ts
packages/runtime-core/src/index.ts

index 423c81d744122a57a4635a49344239359d2c090c..8ba9429f447a55160bef533ff16f9d05a9475713 100644 (file)
@@ -149,17 +149,19 @@ export interface AppContext {
   filters?: Record<string, Function>
 }
 
-type PluginInstallFunction<Options> = Options extends unknown[]
+type PluginInstallFunction<Options = any[]> = Options extends unknown[]
   ? (app: App, ...options: Options) => any
   : (app: App, options: Options) => any
 
+export type ObjectPlugin<Options = any[]> = {
+  install: PluginInstallFunction<Options>
+}
+export type FunctionPlugin<Options = any[]> = PluginInstallFunction<Options> &
+  Partial<ObjectPlugin<Options>>
+
 export type Plugin<Options = any[]> =
-  | (PluginInstallFunction<Options> & {
-      install?: PluginInstallFunction<Options>
-    })
-  | {
-      install: PluginInstallFunction<Options>
-    }
+  | FunctionPlugin<Options>
+  | ObjectPlugin<Options>
 
 export function createAppContext(): AppContext {
   return {
index ab86bfce7dcb16a817447dd12d8979261dce4864..06300cbf68f2d440f745f7ef00e5ea0f775163cd 100644 (file)
@@ -212,6 +212,8 @@ export type {
   AppConfig,
   AppContext,
   Plugin,
+  ObjectPlugin,
+  FunctionPlugin,
   CreateAppFunction,
   OptionMergeFunction
 } from './apiCreateApp'