import { Ref, refSymbol, UnwrapNestedRefs } from './ref'
import { isFunction, NOOP } from '@vue/shared'
-export interface ComputedRef<T> extends Ref<T> {
+export interface ComputedRef<T> extends WritableComputedRef<T> {
readonly value: UnwrapNestedRefs<T>
- readonly effect: ReactiveEffect
}
export interface WritableComputedRef<T> extends Ref<T> {
export function readonly<T extends object>(
target: T
-): Readonly<UnwrapNestedRefs<T>>
-export function readonly(target: object) {
+): Readonly<UnwrapNestedRefs<T>> {
// value is a mutable observable, retrieve its original and return
// a readonly version.
if (reactiveToRaw.has(target)) {
export const refSymbol = Symbol(__DEV__ ? 'refSymbol' : undefined)
-export interface Ref<T> {
+export interface Ref<T = any> {
[refSymbol]: true
value: UnwrapNestedRefs<T>
}
-export type UnwrapNestedRefs<T> = T extends Ref<any> ? T : UnwrapRef<T>
+export type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRef<T>
const convert = (val: any): any => (isObject(val) ? reactive(val) : val)
return v as Ref<T>
}
-export function isRef(v: any): v is Ref<any> {
+export function isRef(v: any): v is Ref {
return v ? v[refSymbol] === true : false
}
array: T extends Array<infer V> ? Array<UnwrapRef<V>> : T
object: { [K in keyof T]: UnwrapRef<T[K]> }
stop: T
-}[T extends Ref<any>
+}[T extends Ref
? 'ref'
: T extends Array<any>
? 'array'
}
function setRef(
- ref: string | Function | Ref<any>,
- oldRef: string | Function | Ref<any> | null,
+ ref: string | Function | Ref,
+ oldRef: string | Function | Ref | null,
parent: ComponentInternalInstance,
value: HostNode | ComponentPublicInstance | null
) {
export interface RawProps {
[key: string]: any
key?: string | number
- ref?: string | Ref<any> | Function
+ ref?: string | Ref | Function
// used to differ from a single VNode object as children
_isVNode?: never
// used to differ from Array children