wip: adjust computed ref type

This commit is contained in:
Evan You 2019-08-16 10:52:45 -04:00
parent e1e4a3854c
commit 3facfa5a55
2 changed files with 5 additions and 3 deletions

View 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
}

View 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> {