diff --git a/packages/core/useVModel/index.ts b/packages/core/useVModel/index.ts index 96d2dfe06f5..f99792907cb 100644 --- a/packages/core/useVModel/index.ts +++ b/packages/core/useVModel/index.ts @@ -1,17 +1,17 @@ import { isDef } from '@vueuse/shared' -import type { UnwrapRef } from 'vue-demi' +import type { Ref, UnwrapRef, WritableComputedRef } from 'vue-demi' import { computed, getCurrentInstance, isVue2, ref, watch } from 'vue-demi' import type { CloneFn } from '../useCloned' import { cloneFnJSON } from '../useCloned' -export interface UseVModelOptions { +export interface UseVModelOptions { /** * When passive is set to `true`, it will use `watch` to sync with props and ref. * Instead of relying on the `v-model` or `.sync` to work. * * @default false */ - passive?: boolean + passive?: Passive /** * When eventName is set, it's value will be used to overwrite the emit event name. * @@ -48,6 +48,20 @@ export interface UseVModelOptions { shouldEmit?: (v: T) => boolean } +export function useVModel

( + props: P, + key?: K, + emit?: (name: Name, ...args: any[]) => void, + options?: UseVModelOptions, +): WritableComputedRef + +export function useVModel

( + props: P, + key?: K, + emit?: (name: Name, ...args: any[]) => void, + options?: UseVModelOptions, +): Ref> + /** * Shorthand for v-model binding, props + emit -> ref * @@ -56,11 +70,11 @@ export interface UseVModelOptions { * @param key (default 'value' in Vue 2 and 'modelValue' in Vue 3) * @param emit */ -export function useVModel

( +export function useVModel

( props: P, key?: K, emit?: (name: Name, ...args: any[]) => void, - options: UseVModelOptions = {}, + options: UseVModelOptions = {}, ) { const { clone = false,