Skip to content

Commit fa4969e

Browse files
authored
feat(types): export ObjectPlugin and FunctionPlugin types (#8946)
close #8577
1 parent 982a145 commit fa4969e

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

packages/runtime-core/src/apiCreateApp.ts

+9-7
Original file line numberDiff line numberDiff line change
@@ -149,17 +149,19 @@ export interface AppContext {
149149
filters?: Record<string, Function>
150150
}
151151

152-
type PluginInstallFunction<Options> = Options extends unknown[]
152+
type PluginInstallFunction<Options = any[]> = Options extends unknown[]
153153
? (app: App, ...options: Options) => any
154154
: (app: App, options: Options) => any
155155

156+
export type ObjectPlugin<Options = any[]> = {
157+
install: PluginInstallFunction<Options>
158+
}
159+
export type FunctionPlugin<Options = any[]> = PluginInstallFunction<Options> &
160+
Partial<ObjectPlugin<Options>>
161+
156162
export type Plugin<Options = any[]> =
157-
| (PluginInstallFunction<Options> & {
158-
install?: PluginInstallFunction<Options>
159-
})
160-
| {
161-
install: PluginInstallFunction<Options>
162-
}
163+
| FunctionPlugin<Options>
164+
| ObjectPlugin<Options>
163165

164166
export function createAppContext(): AppContext {
165167
return {

packages/runtime-core/src/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ export type {
212212
AppConfig,
213213
AppContext,
214214
Plugin,
215+
ObjectPlugin,
216+
FunctionPlugin,
215217
CreateAppFunction,
216218
OptionMergeFunction
217219
} from './apiCreateApp'

0 commit comments

Comments
 (0)