_shallow?: boolean
}
-export type ToRef<T> = T extends Ref ? T : Ref<UnwrapRef<T>>
+export type ToRef<T> = [T] extends [Ref] ? T : Ref<UnwrapRef<T>>
export type ToRefs<T = any> = {
// #2687: somehow using ToRef<T[K]> here turns the resulting type into
// a union of multiple Ref<*> types instead of a single Ref<* | *> type.
proxyRefs,
toRef,
toRefs,
- ToRefs
+ ToRefs,
+ watch
} from './index'
function plainType(arg: number | Ref<number>) {
expectType<Ref<number>>(toRef(obj, 'a'))
expectType<Ref<number>>(toRef(obj, 'b'))
+const objWithUnionProp: { a: string | number } = {
+ a: 1
+}
+
+watch(toRef(objWithUnionProp, 'a'), value => {
+ expectType<string | number>(value)
+})
+
// toRefs
const objRefs = toRefs(obj)
expectType<{