From 7da94ea0dbe7a1bfe3cd2f63012ef94f64bcfa1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=B6=E8=BF=9C=E6=96=B9?= Date: Fri, 15 Dec 2023 22:43:56 +0800 Subject: [PATCH] fix(types): fix `shallowRef` type error --- src/v3/reactivity/ref.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/v3/reactivity/ref.ts b/src/v3/reactivity/ref.ts index 33495806da..9a1d441adc 100644 --- a/src/v3/reactivity/ref.ts +++ b/src/v3/reactivity/ref.ts @@ -51,9 +51,13 @@ declare const ShallowRefMarker: unique symbol export type ShallowRef = Ref & { [ShallowRefMarker]?: true } -export function shallowRef(value: T | Ref): Ref | ShallowRef -export function shallowRef(value: T): T -export function shallowRef(value: T): ShallowRef +export function shallowRef( + value: T +): Ref extends T + ? T extends Ref + ? IfAny, T> + : ShallowRef + : ShallowRef export function shallowRef(): ShallowRef export function shallowRef(value?: unknown) { return createRef(value, true)