Skip to content

Commit

Permalink
fix(types): global component registration type compat w/ defineComponent
Browse files Browse the repository at this point in the history
fix #12622
  • Loading branch information
yyx990803 committed Jul 8, 2022
1 parent b70a258 commit 26ff4bc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 7 additions & 6 deletions types/test/v3/define-component-test.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Vue, { VueConstructor } from '../../index'
import {
Component,
defineComponent,
Expand All @@ -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)
}
})

Expand Down
5 changes: 5 additions & 0 deletions types/vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
(
Expand Down Expand Up @@ -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>,
Expand Down

0 comments on commit 26ff4bc

Please sign in to comment.