Skip to content

Commit

Permalink
fix(types): avoid circular type inference between v2 and v3 instance …
Browse files Browse the repository at this point in the history
…types

fix #12683
  • Loading branch information
yyx990803 committed Jul 22, 2022
1 parent ce6fc14 commit fabc1cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 0 additions & 2 deletions types/v3-component-public-instance.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,7 @@ interface Vue3Instance<
? Partial<Defaults> & Omit<P & PublicProps, keyof Defaults>
: P & PublicProps
>,
ComponentPublicInstance | null,
ComponentPublicInstance,
ComponentPublicInstance[],
Options & MergedComponentOptionsOverride,
EmitFn<E>
> {}
Expand Down
15 changes: 6 additions & 9 deletions types/vue.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
(
Expand All @@ -41,29 +40,27 @@ type NeverFallback<T, D> = [T] extends [never] ? D : T
export interface Vue<
Data = Record<string, any>,
Props = Record<string, any>,
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<Parent, Vue>
readonly $root: NeverFallback<Root, Vue>
readonly $children: NeverFallback<Children, Vue[]>
readonly $parent: NeverFallback<Instance, Vue> | null
readonly $root: NeverFallback<Instance, Vue>
readonly $children: NeverFallback<Instance, Vue>[]
readonly $options: NeverFallback<Options, ComponentOptions<Vue>>
$emit: Emit

// Vue 2 only or shared
readonly $el: Element
readonly $refs: {
[key: string]:
| NeverFallback<Instance, Vue>
| Vue
| Element
| ComponentPublicInstance
| (Vue | Element | ComponentPublicInstance)[]
| (NeverFallback<Instance, Vue> | Vue | Element)[]
| undefined
}
readonly $slots: { [key: string]: VNode[] | undefined }
Expand Down

0 comments on commit fabc1cf

Please sign in to comment.