Skip to content

Commit

Permalink
types: support app.component to be defineComponent (#9662)
Browse files Browse the repository at this point in the history
  • Loading branch information
pikax authored Nov 22, 2023
1 parent fc772db commit 1c525f7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
14 changes: 13 additions & 1 deletion packages/dts-test/appUse.test-d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createApp, App, Plugin } from 'vue'
import { createApp, App, Plugin, defineComponent } from 'vue'

const app = createApp({})

Expand Down Expand Up @@ -93,3 +93,15 @@ const PluginTyped: Plugin<PluginOptions> = (app, options) => {}
// @ts-expect-error: needs options
app.use(PluginTyped)
app.use(PluginTyped, { option2: 2, option3: true })

// vuetify usage
const key: string = ''
const aliases: Record<string, any> = {}
app.component(
key,
defineComponent({
...aliases[key],
name: key,
aliasName: aliases[key].name
})
)
3 changes: 2 additions & 1 deletion packages/runtime-core/src/apiCreateApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { version } from '.'
import { installAppCompatProperties } from './compat/global'
import { NormalizedPropsOptions } from './componentProps'
import { ObjectEmitsOptions } from './componentEmits'
import { DefineComponent } from './apiDefineComponent'

export interface App<HostElement = any> {
version: string
Expand All @@ -40,7 +41,7 @@ export interface App<HostElement = any> {

mixin(mixin: ComponentOptions): this
component(name: string): Component | undefined
component(name: string, component: Component): this
component(name: string, component: Component | DefineComponent): this
directive(name: string): Directive | undefined
directive(name: string, directive: Directive): this
mount(
Expand Down

0 comments on commit 1c525f7

Please sign in to comment.