Skip to content

Commit

Permalink
types: export object and function plugin
Browse files Browse the repository at this point in the history
closes #8577
  • Loading branch information
sxzz committed Aug 9, 2023
1 parent 3be4e3c commit fabdea4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/runtime-core/src/apiCreateApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,17 +155,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 {
Expand Down
2 changes: 2 additions & 0 deletions packages/runtime-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export type {
App,
AppConfig,
AppContext,
ObjectPlugin,
FunctionPlugin,
Plugin,
CreateAppFunction,
OptionMergeFunction
Expand Down

0 comments on commit fabdea4

Please sign in to comment.