diff --git a/packages/reactivity/src/index.ts b/packages/reactivity/src/index.ts index 0ac9e5f3..bdfa64f6 100644 --- a/packages/reactivity/src/index.ts +++ b/packages/reactivity/src/index.ts @@ -8,7 +8,8 @@ export { customRef, triggerRef, Ref, - UnwrapRef + UnwrapRef, + ToRefs } from './ref' export { reactive, diff --git a/packages/reactivity/src/ref.ts b/packages/reactivity/src/ref.ts index 22d9c233..470cd41f 100644 --- a/packages/reactivity/src/ref.ts +++ b/packages/reactivity/src/ref.ts @@ -20,6 +20,8 @@ export interface Ref { value: T } +export type ToRefs = { [K in keyof T]: Ref } + const convert = (val: T): T => isObject(val) ? reactive(val) : val @@ -108,9 +110,7 @@ export function customRef(factory: CustomRefFactory): Ref { return r as any } -export function toRefs( - object: T -): { [K in keyof T]: Ref } { +export function toRefs(object: T): ToRefs { if (__DEV__ && !isProxy(object)) { console.warn(`toRefs() expects a reactive object but received a plain one.`) } diff --git a/packages/runtime-core/src/index.ts b/packages/runtime-core/src/index.ts index 3bf99a71..831e6467 100644 --- a/packages/runtime-core/src/index.ts +++ b/packages/runtime-core/src/index.ts @@ -153,7 +153,8 @@ export { Ref, ComputedRef, UnwrapRef, - WritableComputedOptions + WritableComputedOptions, + ToRefs } from '@vue/reactivity' export { // types