wip: adjust computed ref type
This commit is contained in:
parent
e1e4a3854c
commit
3facfa5a55
@ -1,8 +1,8 @@
|
|||||||
import { effect, ReactiveEffect, activeReactiveEffectStack } from './effect'
|
import { effect, ReactiveEffect, activeReactiveEffectStack } from './effect'
|
||||||
import { knownValues } from './ref'
|
import { UnwrapNestedRefs, knownValues } from './ref'
|
||||||
|
|
||||||
export interface ComputedRef<T> {
|
export interface ComputedRef<T> {
|
||||||
readonly value: T
|
readonly value: UnwrapNestedRefs<T>
|
||||||
readonly effect: ReactiveEffect
|
readonly effect: ReactiveEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,9 +6,11 @@ import { reactive } from './reactive'
|
|||||||
export const knownValues = new WeakSet()
|
export const knownValues = new WeakSet()
|
||||||
|
|
||||||
export interface Ref<T> {
|
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)
|
const convert = (val: any): any => (isObject(val) ? reactive(val) : val)
|
||||||
|
|
||||||
export function ref<T>(raw: T): Ref<T> {
|
export function ref<T>(raw: T): Ref<T> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user