From fabc1cf89f55dd7f3f95fa7890d2540f40e9f845 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 22 Jul 2022 10:06:43 +0800 Subject: [PATCH] fix(types): avoid circular type inference between v2 and v3 instance types fix #12683 --- types/v3-component-public-instance.d.ts | 2 -- types/vue.d.ts | 15 ++++++--------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/types/v3-component-public-instance.d.ts b/types/v3-component-public-instance.d.ts index a5bf670139..3586f4031e 100644 --- a/types/v3-component-public-instance.d.ts +++ b/types/v3-component-public-instance.d.ts @@ -179,9 +179,7 @@ interface Vue3Instance< ? Partial & Omit

: P & PublicProps >, - ComponentPublicInstance | null, ComponentPublicInstance, - ComponentPublicInstance[], Options & MergedComponentOptionsOverride, EmitFn > {} diff --git a/types/vue.d.ts b/types/vue.d.ts index aaf471dd2c..74bce2c8a4 100644 --- a/types/vue.d.ts +++ b/types/vue.d.ts @@ -14,7 +14,6 @@ import { VNode, VNodeData, VNodeChildren, NormalizedScopedSlot } from './vnode' import { PluginFunction, PluginObject } from './plugin' import { DefineComponent } from './v3-define-component' import { nextTick } from './v3-generated' -import { ComponentPublicInstance } from './v3-component-public-instance' export interface CreateElement { ( @@ -41,18 +40,16 @@ type NeverFallback = [T] extends [never] ? D : T export interface Vue< Data = Record, Props = Record, - Parent = never, - Root = never, - Children = never, + Instance = never, Options = never, Emit = (event: string, ...args: any[]) => Vue > { // properties with different types in defineComponent() readonly $data: Data readonly $props: Props - readonly $parent: NeverFallback - readonly $root: NeverFallback - readonly $children: NeverFallback + readonly $parent: NeverFallback | null + readonly $root: NeverFallback + readonly $children: NeverFallback[] readonly $options: NeverFallback> $emit: Emit @@ -60,10 +57,10 @@ export interface Vue< readonly $el: Element readonly $refs: { [key: string]: + | NeverFallback | Vue | Element - | ComponentPublicInstance - | (Vue | Element | ComponentPublicInstance)[] + | (NeverFallback | Vue | Element)[] | undefined } readonly $slots: { [key: string]: VNode[] | undefined }