From c2f762249cfb93e5db75a04817f5ebe95cbbcee3 Mon Sep 17 00:00:00 2001 From: KazariEX <1364035137@qq.com> Date: Mon, 24 Feb 2025 14:34:22 +0800 Subject: [PATCH] fix(types): keep readonly infomation during unwrap refs --- packages/reactivity/src/ref.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 6b8d54181..6f1cacbd3 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -486,9 +486,15 @@ function propertyToRef( export interface RefUnwrapBailTypes {} export type ShallowUnwrapRef = { - [K in keyof T]: DistributeRef + readonly [K in keyof Pick>]: DistributeRef +} & { + [K in keyof Omit>]: DistributeRef } +type ReadonlyKeys = { + [K in keyof O]: O[K] extends Readonly ? K : never +}[keyof O] + type DistributeRef = T extends Ref ? V : T export type UnwrapRef =