From c97bb84d0b0a16b012f886b6498e924415ed63e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=B1=E5=90=B9=E8=89=B2=E5=BE=A1=E5=AE=88?= <85992002+KazariEX@users.noreply.github.com> Date: Thu, 3 Oct 2024 23:22:57 +0800 Subject: [PATCH] fix(types): infer the first generic type of `Ref` correctly (#12094) --- packages/reactivity/src/reactive.ts | 2 +- packages/reactivity/src/ref.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/reactivity/src/reactive.ts b/packages/reactivity/src/reactive.ts index 7d9c33aa4d0..729c854965e 100644 --- a/packages/reactivity/src/reactive.ts +++ b/packages/reactivity/src/reactive.ts @@ -167,7 +167,7 @@ export type DeepReadonly = T extends Builtin ? WeakSet> : T extends Promise ? Promise> - : T extends Ref + : T extends Ref ? Readonly>> : T extends {} ? { readonly [K in keyof T]: DeepReadonly } diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 43b26b78f9d..6b8d541819d 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -489,12 +489,12 @@ export type ShallowUnwrapRef = { [K in keyof T]: DistributeRef } -type DistributeRef = T extends Ref ? V : T +type DistributeRef = T extends Ref ? V : T export type UnwrapRef = - T extends ShallowRef + T extends ShallowRef ? V - : T extends Ref + : T extends Ref ? UnwrapRefSimple : UnwrapRefSimple