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 b9ba122
Showing 1 changed file with 9 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

0 comments on commit b9ba122

Please sign in to comment.