fix (types): do not unwrap refs in toRefs (#4966)

This commit is contained in:
JensDll
2021-11-25 10:39:09 +01:00
committed by GitHub
parent f2d2d7b2d2
commit c6cd6a7938
2 changed files with 40 additions and 40 deletions

View File

@@ -190,9 +190,7 @@ export function customRef<T>(factory: CustomRefFactory<T>): Ref<T> {
}
export type ToRefs<T = any> = {
// #2687: somehow using ToRef<T[K]> here turns the resulting type into
// a union of multiple Ref<*> types instead of a single Ref<* | *> type.
[K in keyof T]: T[K] extends Ref ? T[K] : Ref<UnwrapRef<T[K]>>
[K in keyof T]: ToRef<T[K]>
}
export function toRefs<T extends object>(object: T): ToRefs<T> {
if (__DEV__ && !isProxy(object)) {