Skip to content

Commit

Permalink
feat(types): export ObjectPlugin and FunctionPlugin types (#8946)
Browse files Browse the repository at this point in the history
close #8577
  • Loading branch information
sxzz committed Dec 11, 2023
1 parent 982a145 commit fa4969e
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 @@ -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 {
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 @@ -212,6 +212,8 @@ export type {
AppConfig,
AppContext,
Plugin,
ObjectPlugin,
FunctionPlugin,
CreateAppFunction,
OptionMergeFunction
} from './apiCreateApp'
Expand Down

0 comments on commit fa4969e

Please sign in to comment.