fix(types): global component registration type compat w/ defineComponent

fix #12622
This commit is contained in:
Evan You 2022-07-08 10:39:23 +08:00
parent b70a2585fc
commit 26ff4bc0ed
2 changed files with 12 additions and 6 deletions

View File

@ -1,3 +1,4 @@
import Vue, { VueConstructor } from '../../index'
import {
Component,
defineComponent,
@ -8,12 +9,12 @@ import {
} from '../../index'
import { describe, test, expectType, expectError, IsUnion } from '../utils'
defineComponent({
props: {
foo: Number
},
render() {
this.foo
describe('compat with v2 APIs', () => {
const comp = defineComponent({})
Vue.component('foo', comp)
function install(app: VueConstructor) {
app.component('foo', comp)
}
})

5
types/vue.d.ts vendored
View File

@ -14,6 +14,7 @@ import {
} from './options'
import { VNode, VNodeData, VNodeChildren, NormalizedScopedSlot } from './vnode'
import { PluginFunction, PluginObject } from './plugin'
import { DefineComponent } from './v3-define-component'
export interface CreateElement {
(
@ -313,6 +314,10 @@ export interface VueConstructor<V extends Vue = Vue> {
id: string,
definition?: ComponentOptions<V>
): ExtendedVue<V, {}, {}, {}, {}, {}>
component<T extends DefineComponent<any, any, any, any, any, any, any, any>>(
id: string,
definition?: T
): T
use<T>(
plugin: PluginObject<T> | PluginFunction<T>,