]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
wip: adjust computed ref type
authorEvan You <yyx990803@gmail.com>
Fri, 16 Aug 2019 14:52:45 +0000 (10:52 -0400)
committerEvan You <yyx990803@gmail.com>
Fri, 16 Aug 2019 14:52:45 +0000 (10:52 -0400)
packages/reactivity/src/computed.ts
packages/reactivity/src/ref.ts

index b23bdfcde822a18e9b89897636b064c1050bef21..9ffbbf0b52b6cbaf4e97ba6cdbc8a9943154c75c 100644 (file)
@@ -1,8 +1,8 @@
 import { effect, ReactiveEffect, activeReactiveEffectStack } from './effect'
-import { knownValues } from './ref'
+import { UnwrapNestedRefs, knownValues } from './ref'
 
 export interface ComputedRef<T> {
-  readonly value: T
+  readonly value: UnwrapNestedRefs<T>
   readonly effect: ReactiveEffect
 }
 
index d0dc26fed971a0e248c2a94d810fa481b4fa26fc..6c2e134ea2f2854c92775714cdf9b57e31722e0d 100644 (file)
@@ -6,9 +6,11 @@ import { reactive } from './reactive'
 export const knownValues = new WeakSet()
 
 export interface Ref<T> {
-  value: T extends Ref<infer V> ? Ref<V> : UnwrapRef<T>
+  value: UnwrapNestedRefs<T>
 }
 
+export type UnwrapNestedRefs<T> = T extends Ref<infer V> ? Ref<V> : UnwrapRef<T>
+
 const convert = (val: any): any => (isObject(val) ? reactive(val) : val)
 
 export function ref<T>(raw: T): Ref<T> {