@@ -16,7 +16,7 @@ import {
16
16
toRaw ,
17
17
toReactive ,
18
18
} from './reactive'
19
- import type { ComputedRef } from './computed'
19
+ import type { ComputedRef , WritableComputedRef } from './computed'
20
20
import { ReactiveFlags , TrackOpTypes , TriggerOpTypes } from './constants'
21
21
import { warn } from './warning'
22
22
@@ -192,8 +192,13 @@ export function triggerRef(ref: Ref) {
192
192
}
193
193
}
194
194
195
- export type MaybeRef < T = any > = T | Ref < T >
196
- export type MaybeRefOrGetter < T = any > = MaybeRef < T > | ( ( ) => T )
195
+ export type MaybeRef < T = any > =
196
+ | T
197
+ | Ref < T >
198
+ | ShallowRef < T >
199
+ | WritableComputedRef < T >
200
+
201
+ export type MaybeRefOrGetter < T = any > = MaybeRef < T > | ComputedRef < T > | ( ( ) => T )
197
202
198
203
/**
199
204
* Returns the inner value if the argument is a ref, otherwise return the
@@ -211,7 +216,7 @@ export type MaybeRefOrGetter<T = any> = MaybeRef<T> | (() => T)
211
216
* @param ref - Ref or plain value to be converted into the plain value.
212
217
* @see {@link https://vuejs.org/api/reactivity-utilities.html#unref }
213
218
*/
214
- export function unref < T > ( ref : MaybeRef < T > | ComputedRef < T > | ShallowRef < T > ) : T {
219
+ export function unref < T > ( ref : MaybeRef < T > | ComputedRef < T > ) : T {
215
220
return isRef ( ref ) ? ref . value : ref
216
221
}
217
222
@@ -231,9 +236,7 @@ export function unref<T>(ref: MaybeRef<T> | ComputedRef<T> | ShallowRef<T>): T {
231
236
* @param source - A getter, an existing ref, or a non-function value.
232
237
* @see {@link https://vuejs.org/api/reactivity-utilities.html#tovalue }
233
238
*/
234
- export function toValue < T > (
235
- source : MaybeRefOrGetter < T > | ComputedRef < T > | ShallowRef < T > ,
236
- ) : T {
239
+ export function toValue < T > ( source : MaybeRefOrGetter < T > ) : T {
237
240
return isFunction ( source ) ? source ( ) : unref ( source )
238
241
}
239
242
0 commit comments