Skip to content

Commit 47dbc22

Browse files
committed
types(runtime-core): enable plugin option types
This enables type inference for: 1. The options arg of a plugin's install function 2. The options passed to createApp().use()
1 parent 82e3f2d commit 47dbc22

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

packages/runtime-core/src/apiCreateApp.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { ObjectEmitsOptions } from './componentEmits'
2828
export interface App<HostElement = any> {
2929
version: string
3030
config: AppConfig
31-
use(plugin: Plugin, ...options: any[]): this
31+
use<Option>(plugin: Plugin<Option>, ...options: Option[]): this
3232
mixin(mixin: ComponentOptions): this
3333
component(name: string): Component | undefined
3434
component(name: string, component: Component): this
@@ -137,12 +137,12 @@ export interface AppContext {
137137
filters?: Record<string, Function>
138138
}
139139

140-
type PluginInstallFunction = (app: App, ...options: any[]) => any
140+
type PluginInstallFunction<Option> = (app: App, ...options: Option[]) => any
141141

142-
export type Plugin =
143-
| (PluginInstallFunction & { install?: PluginInstallFunction })
142+
export type Plugin<Option = any> =
143+
| PluginInstallFunction<Option> & { install?: PluginInstallFunction<Option> }
144144
| {
145-
install: PluginInstallFunction
145+
install: PluginInstallFunction<Option>
146146
}
147147

148148
export function createAppContext(): AppContext {

0 commit comments

Comments
 (0)