From: Evan You Date: Fri, 16 Aug 2019 14:52:45 +0000 (-0400) Subject: wip: adjust computed ref type X-Git-Tag: v3.0.0-alpha.0~923 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3facfa5a551b7be1c1c51c035b529fed7d5d54cf;p=thirdparty%2Fvuejs%2Fcore.git wip: adjust computed ref type --- diff --git a/packages/reactivity/src/computed.ts b/packages/reactivity/src/computed.ts index b23bdfcde8..9ffbbf0b52 100644 --- a/packages/reactivity/src/computed.ts +++ b/packages/reactivity/src/computed.ts @@ -1,8 +1,8 @@ import { effect, ReactiveEffect, activeReactiveEffectStack } from './effect' -import { knownValues } from './ref' +import { UnwrapNestedRefs, knownValues } from './ref' export interface ComputedRef { - readonly value: T + readonly value: UnwrapNestedRefs readonly effect: ReactiveEffect } diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index d0dc26fed9..6c2e134ea2 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -6,9 +6,11 @@ import { reactive } from './reactive' export const knownValues = new WeakSet() export interface Ref { - value: T extends Ref ? Ref : UnwrapRef + value: UnwrapNestedRefs } +export type UnwrapNestedRefs = T extends Ref ? Ref : UnwrapRef + const convert = (val: any): any => (isObject(val) ? reactive(val) : val) export function ref(raw: T): Ref {