Skip to content

Commit fabc1cf

Browse files
committed
fix(types): avoid circular type inference between v2 and v3 instance types
fix #12683
1 parent ce6fc14 commit fabc1cf

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

Diff for: types/v3-component-public-instance.d.ts

-2
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,7 @@ interface Vue3Instance<
179179
? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults>
180180
: P & PublicProps
181181
>,
182-
ComponentPublicInstance | null,
183182
ComponentPublicInstance,
184-
ComponentPublicInstance[],
185183
Options & MergedComponentOptionsOverride,
186184
EmitFn<E>
187185
> {}

Diff for: types/vue.d.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { VNode, VNodeData, VNodeChildren, NormalizedScopedSlot } from './vnode'
1414
import { PluginFunction, PluginObject } from './plugin'
1515
import { DefineComponent } from './v3-define-component'
1616
import { nextTick } from './v3-generated'
17-
import { ComponentPublicInstance } from './v3-component-public-instance'
1817

1918
export interface CreateElement {
2019
(
@@ -41,29 +40,27 @@ type NeverFallback<T, D> = [T] extends [never] ? D : T
4140
export interface Vue<
4241
Data = Record<string, any>,
4342
Props = Record<string, any>,
44-
Parent = never,
45-
Root = never,
46-
Children = never,
43+
Instance = never,
4744
Options = never,
4845
Emit = (event: string, ...args: any[]) => Vue
4946
> {
5047
// properties with different types in defineComponent()
5148
readonly $data: Data
5249
readonly $props: Props
53-
readonly $parent: NeverFallback<Parent, Vue>
54-
readonly $root: NeverFallback<Root, Vue>
55-
readonly $children: NeverFallback<Children, Vue[]>
50+
readonly $parent: NeverFallback<Instance, Vue> | null
51+
readonly $root: NeverFallback<Instance, Vue>
52+
readonly $children: NeverFallback<Instance, Vue>[]
5653
readonly $options: NeverFallback<Options, ComponentOptions<Vue>>
5754
$emit: Emit
5855

5956
// Vue 2 only or shared
6057
readonly $el: Element
6158
readonly $refs: {
6259
[key: string]:
60+
| NeverFallback<Instance, Vue>
6361
| Vue
6462
| Element
65-
| ComponentPublicInstance
66-
| (Vue | Element | ComponentPublicInstance)[]
63+
| (NeverFallback<Instance, Vue> | Vue | Element)[]
6764
| undefined
6865
}
6966
readonly $slots: { [key: string]: VNode[] | undefined }

0 commit comments

Comments
 (0)