Skip to content

Commit 1c525f7

Browse files
authored
types: support app.component to be defineComponent (#9662)
1 parent fc772db commit 1c525f7

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

packages/dts-test/appUse.test-d.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createApp, App, Plugin } from 'vue'
1+
import { createApp, App, Plugin, defineComponent } from 'vue'
22

33
const app = createApp({})
44

@@ -93,3 +93,15 @@ const PluginTyped: Plugin<PluginOptions> = (app, options) => {}
9393
// @ts-expect-error: needs options
9494
app.use(PluginTyped)
9595
app.use(PluginTyped, { option2: 2, option3: true })
96+
97+
// vuetify usage
98+
const key: string = ''
99+
const aliases: Record<string, any> = {}
100+
app.component(
101+
key,
102+
defineComponent({
103+
...aliases[key],
104+
name: key,
105+
aliasName: aliases[key].name
106+
})
107+
)

packages/runtime-core/src/apiCreateApp.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import { version } from '.'
2727
import { installAppCompatProperties } from './compat/global'
2828
import { NormalizedPropsOptions } from './componentProps'
2929
import { ObjectEmitsOptions } from './componentEmits'
30+
import { DefineComponent } from './apiDefineComponent'
3031

3132
export interface App<HostElement = any> {
3233
version: string
@@ -40,7 +41,7 @@ export interface App<HostElement = any> {
4041

4142
mixin(mixin: ComponentOptions): this
4243
component(name: string): Component | undefined
43-
component(name: string, component: Component): this
44+
component(name: string, component: Component | DefineComponent): this
4445
directive(name: string): Directive | undefined
4546
directive(name: string, directive: Directive): this
4647
mount(

0 commit comments

Comments
 (0)