]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
types(reactivity-transform): improve type readability for reactive variables
authorEvan You <yyx990803@gmail.com>
Sat, 7 May 2022 02:37:07 +0000 (10:37 +0800)
committerEvan You <yyx990803@gmail.com>
Sat, 7 May 2022 02:37:07 +0000 (10:37 +0800)
packages/vue/macros.d.ts

index a0a9f54d306f8943039ad157360d11f6bace02e3..41aefd77d7fea0cb7e60487b4846b5ba08f35819 100644 (file)
@@ -16,17 +16,21 @@ export declare const enum RefTypes {
   WritableComputedRef = 3
 }
 
-type RefValue<T> = T extends null | undefined
-  ? T
-  : T & { [RefType]?: RefTypes.Ref }
+type RefValue<T> = T extends null | undefined ? T : ReactiveVariable<T>
 
-type ComputedRefValue<T> = T extends null | undefined
-  ? T
-  : T & { [RefType]?: RefTypes.ComputedRef }
+type ReactiveVariable<T> = T & { [RefType]?: RefTypes.Ref }
+
+type ComputedRefValue<T> = T extends null | undefined ? T : ComputedVariable<T>
+
+type ComputedVariable<T> = T & { [RefType]?: RefTypes.ComputedRef }
 
 type WritableComputedRefValue<T> = T extends null | undefined
   ? T
-  : T & { [RefType]?: RefTypes.WritableComputedRef }
+  : WritableComputedVariable<T>
+
+type WritableComputedVariable<T> = T & {
+  [RefType]?: RefTypes.WritableComputedRef
+}
 
 type NormalObject<T extends object> = T & { [RefType]?: never }