From 0683a022ec83694e29636f64aaf3c04012e9a7f0 Mon Sep 17 00:00:00 2001 From: Evan You Date: Sat, 7 May 2022 10:37:07 +0800 Subject: [PATCH] types(reactivity-transform): improve type readability for reactive variables --- packages/vue/macros.d.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/vue/macros.d.ts b/packages/vue/macros.d.ts index a0a9f54d306..41aefd77d7f 100644 --- a/packages/vue/macros.d.ts +++ b/packages/vue/macros.d.ts @@ -16,17 +16,21 @@ export declare const enum RefTypes { WritableComputedRef = 3 } -type RefValue = T extends null | undefined - ? T - : T & { [RefType]?: RefTypes.Ref } +type RefValue = T extends null | undefined ? T : ReactiveVariable -type ComputedRefValue = T extends null | undefined - ? T - : T & { [RefType]?: RefTypes.ComputedRef } +type ReactiveVariable = T & { [RefType]?: RefTypes.Ref } + +type ComputedRefValue = T extends null | undefined ? T : ComputedVariable + +type ComputedVariable = T & { [RefType]?: RefTypes.ComputedRef } type WritableComputedRefValue = T extends null | undefined ? T - : T & { [RefType]?: RefTypes.WritableComputedRef } + : WritableComputedVariable + +type WritableComputedVariable = T & { + [RefType]?: RefTypes.WritableComputedRef +} type NormalObject = T & { [RefType]?: never }