From 7942a19b8d4927b551734c97100a8e306c37a0f8 Mon Sep 17 00:00:00 2001 From: Machete Date: Fri, 31 Dec 2021 20:18:25 +0800 Subject: [PATCH] fix(types): make `toRefs` return correct type(fix #5188) (#5188) --- packages/reactivity/src/ref.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 55059485d6c..4cafff4d7bb 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -5,6 +5,7 @@ import { isProxy, toRaw, isReactive, toReactive } from './reactive' import type { ShallowReactiveMarker } from './reactive' import { CollectionTypes } from './collectionHandlers' import { createDep, Dep } from './dep' +import { IfAny } from 'packages/runtime-core/src/helpers/typeUtils' declare const RefSymbol: unique symbol @@ -222,7 +223,8 @@ class ObjectRefImpl { } } -export type ToRef = [T] extends [Ref] ? T : Ref +export type ToRef = IfAny,[T] extends [Ref] ? T : Ref> + export function toRef( object: T,