From 1ae22756d88251a7b60b383308198f7117d1c535 Mon Sep 17 00:00:00 2001 From: YangLGggggggggg <46318880+yangliguo7@users.noreply.github.com> Date: Mon, 23 Sep 2024 06:12:04 +0000 Subject: [PATCH] perf(ref): optimize the display type of ref --- 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 1de8b9e3317..551ea24b24c 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -45,6 +45,8 @@ export function isRef(r: any): r is Ref { return r ? r[ReactiveFlags.IS_REF] === true : false } +export type TypeRef = Ref, UnwrapRef | T> + /** * Takes an inner value and returns a reactive and mutable ref object, which * has a single property `.value` that points to the inner value. @@ -54,7 +56,7 @@ export function isRef(r: any): r is Ref { */ export function ref( value: T, -): [T] extends [Ref] ? IfAny, T> : Ref, UnwrapRef | T> +): [T] extends [Ref] ? IfAny, T> : TypeRef export function ref(): Ref export function ref(value?: unknown) { return createRef(value, false)