From 26ff4bc0ed75d8bf7921523a2e546df24ec81d8f Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 8 Jul 2022 10:39:23 +0800 Subject: [PATCH] fix(types): global component registration type compat w/ defineComponent fix #12622 --- types/test/v3/define-component-test.tsx | 13 +++++++------ types/vue.d.ts | 5 +++++ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/types/test/v3/define-component-test.tsx b/types/test/v3/define-component-test.tsx index 7bdbdb82444..9b01e3e45f4 100644 --- a/types/test/v3/define-component-test.tsx +++ b/types/test/v3/define-component-test.tsx @@ -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) } }) diff --git a/types/vue.d.ts b/types/vue.d.ts index afa66b5c2c5..82cad69e793 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -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 { id: string, definition?: ComponentOptions ): ExtendedVue + component>( + id: string, + definition?: T + ): T use( plugin: PluginObject | PluginFunction,