Skip to content

Commit

Permalink
fix(useVModels): type error with passive: true (#3362)
Browse files Browse the repository at this point in the history
  • Loading branch information
chaii3 committed Oct 7, 2023
1 parent ed00453 commit 51f012b
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions packages/core/useVModels/index.ts
Expand Up @@ -8,15 +8,32 @@ import { useVModel } from '../useVModel'
* @see https://vueuse.org/useVModels
* @param props
* @param emit
* @param options
*/
export function useVModels<P extends object, Name extends string>(
props: P,
emit?: (name: Name, ...args: any[]) => void,
options: UseVModelOptions<any> = {},
options?: UseVModelOptions<any, true>,
): ToRefs<P>
export function useVModels<P extends object, Name extends string>(
props: P,
emit?: (name: Name, ...args: any[]) => void,
options?: UseVModelOptions<any, false>,
): ToRefs<P>
export function useVModels<P extends object, Name extends string, Passive extends boolean>(
props: P,
emit?: (name: Name, ...args: any[]) => void,
options: UseVModelOptions<any, Passive> = {},
): ToRefs<P> {
const ret: any = {}

for (const key in props)
ret[key] = useVModel(props, key, emit, options)
for (const key in props) {
ret[key] = useVModel(
props,
key,
emit,
options as Parameters<typeof useVModel>[3],
)
}
return ret
}

0 comments on commit 51f012b

Please sign in to comment.