Skip to content

Commit ebedccb

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 de954f4 commit ebedccb

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
@@ -27,7 +27,7 @@ import { ObjectEmitsOptions } from './componentEmits'
2727
export interface App<HostElement = any> {
2828
version: string
2929
config: AppConfig
30-
use(plugin: Plugin, ...options: any[]): this
30+
use<Option>(plugin: Plugin<Option>, ...options: Option[]): this
3131
mixin(mixin: ComponentOptions): this
3232
component(name: string): Component | undefined
3333
component(name: string, component: Component): this
@@ -130,12 +130,12 @@ export interface AppContext {
130130
filters?: Record<string, Function>
131131
}
132132

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

135-
export type Plugin =
136-
| PluginInstallFunction & { install?: PluginInstallFunction }
135+
export type Plugin<Option = any> =
136+
| PluginInstallFunction<Option> & { install?: PluginInstallFunction<Option> }
137137
| {
138-
install: PluginInstallFunction
138+
install: PluginInstallFunction<Option>
139139
}
140140

141141
export function createAppContext(): AppContext {

0 commit comments

Comments
 (0)