diff --git a/packages/core/unrefElement/index.ts b/packages/core/unrefElement/index.ts index cd018051f3f..712be030647 100644 --- a/packages/core/unrefElement/index.ts +++ b/packages/core/unrefElement/index.ts @@ -3,14 +3,17 @@ import { unref } from 'vue-demi' import type { MaybeRef } from '@vueuse/shared' export type VueInstance = ComponentPublicInstance -export type MaybeElementRef = MaybeRef +export type MaybeElementRef = MaybeRef +export type MaybeElement = HTMLElement | SVGElement | VueInstance | undefined | null + +export type UnRefElementReturn = T extends VueInstance ? Exclude : T | undefined /** * Get the dom element of a ref of element or Vue component instance * * @param elRef */ -export function unrefElement(elRef: MaybeElementRef): HTMLElement | SVGElement | undefined { +export function unrefElement(elRef: MaybeElementRef): UnRefElementReturn { const plain = unref(elRef) return (plain as VueInstance)?.$el ?? plain }