expectType<string>(ss.value.name)
})
-describe('allow getter and setter types to be unrelated', <T>() => {
- const a = { b: ref(0) }
- const c = ref(a)
- c.value = a
-
- const d = {} as T
- const e = ref(d)
- e.value = d
-})
-
// shallowRef
type Status = 'initial' | 'ready' | 'invalidating'
const shallowStatus = shallowRef<Status>('initial')
import {
type ComputedRef,
- type MaybeRef,
type Ref,
computed,
defineComponent,
expectType<{ foo: string }>(value)
})
}
-
-{
- const css: MaybeRef<string> = ''
- watch(ref(css), value => {
- expectType<string>(value)
- })
-}
declare const RefSymbol: unique symbol
export declare const RawSymbol: unique symbol
-export interface Ref<T = any, S = T> {
- get value(): T
- set value(_: S)
+export interface Ref<T = any> {
+ value: T
/**
* Type differentiator only.
* We need this to be in public d.ts but don't want it to show up in IDE
* @param value - The object to wrap in the ref.
* @see {@link https://vuejs.org/api/reactivity-core.html#ref}
*/
-export function ref<T>(value: T): Ref<UnwrapRef<T>, UnwrapRef<T> | T>
+export function ref<T>(value: T): Ref<UnwrapRef<T>>
export function ref<T = any>(): Ref<T | undefined>
export function ref(value?: unknown) {
return createRef(value, false)
export type WatchEffect = (onCleanup: OnCleanup) => void
-export type WatchSource<T = any> = Ref<T, any> | ComputedRef<T> | (() => T)
+export type WatchSource<T = any> = Ref<T> | ComputedRef<T> | (() => T)
export type WatchCallback<V = any, OV = any> = (
value: V,