feat(types): export ObjectPlugin and FunctionPlugin types (#8946)

close #8577
This commit is contained in:
三咲智子 Kevin Deng 2023-12-11 22:04:56 +08:00 committed by GitHub
parent 982a145d38
commit fa4969e7a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -149,17 +149,19 @@ export interface AppContext {
filters?: Record<string, Function> 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
: (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[]> = export type Plugin<Options = any[]> =
| (PluginInstallFunction<Options> & { | FunctionPlugin<Options>
install?: PluginInstallFunction<Options> | ObjectPlugin<Options>
})
| {
install: PluginInstallFunction<Options>
}
export function createAppContext(): AppContext { export function createAppContext(): AppContext {
return { return {

View File

@ -212,6 +212,8 @@ export type {
AppConfig, AppConfig,
AppContext, AppContext,
Plugin, Plugin,
ObjectPlugin,
FunctionPlugin,
CreateAppFunction, CreateAppFunction,
OptionMergeFunction OptionMergeFunction
} from './apiCreateApp' } from './apiCreateApp'