From: 山吹色御守 <85992002+KazariEX@users.noreply.github.com> Date: Thu, 3 Oct 2024 15:22:57 +0000 (+0800) Subject: fix(types): infer the first generic type of `Ref` correctly (#12094) X-Git-Tag: v3.5.11~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c97bb84d0b0a16b012f886b6498e924415ed63e5;p=thirdparty%2Fvuejs%2Fcore.git fix(types): infer the first generic type of `Ref` correctly (#12094) --- diff --git a/packages/reactivity/src/reactive.ts b/packages/reactivity/src/reactive.ts index 7d9c33aa4d..729c854965 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 43b26b78f9..6b8d541819 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