From 570e13f3f272f7497057492dda858213bd74961a Mon Sep 17 00:00:00 2001 From: Othmane BENTALEB Date: Thu, 5 Oct 2023 10:33:43 +0200 Subject: [PATCH] fix(reactivity): unwrapped refs typing (fix #9314) --- packages/reactivity/src/ref.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 915f5760878..6ce73b63ba4 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -490,14 +490,25 @@ export type UnwrapRef = T extends ShallowRef ? UnwrapRefSimple : UnwrapRefSimple +type UnwrapRefCollection = T extends Set + ? Set> + : T extends Map + ? Map> + : T extends WeakSet + ? WeakSet> + : T extends WeakMap + ? WeakMap> + : T + export type UnwrapRefSimple = T extends | Function - | CollectionTypes | BaseTypes | Ref | RefUnwrapBailTypes[keyof RefUnwrapBailTypes] | { [RawSymbol]?: true } ? T + : T extends CollectionTypes + ? UnwrapRefCollection : T extends ReadonlyArray ? { [K in keyof T]: UnwrapRefSimple } : T extends object & { [ShallowReactiveMarker]?: never }