]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
feat(types): expose `ToRefs` type (#1037)
authorCarlos Rodrigues <carlos@hypermob.co.uk>
Fri, 24 Apr 2020 17:10:16 +0000 (18:10 +0100)
committerGitHub <noreply@github.com>
Fri, 24 Apr 2020 17:10:16 +0000 (13:10 -0400)
packages/reactivity/src/index.ts
packages/reactivity/src/ref.ts
packages/runtime-core/src/index.ts

index 0ac9e5f3cc3679e2cb558b841536c22f59dfddab..bdfa64f6995e0b4e5a56824c48924da9eec0100e 100644 (file)
@@ -8,7 +8,8 @@ export {
   customRef,
   triggerRef,
   Ref,
-  UnwrapRef
+  UnwrapRef,
+  ToRefs
 } from './ref'
 export {
   reactive,
index 22d9c23302516ee6a805c6e37f463b771d2bbdb0..470cd41fcabc12778b87f34d1062147402f9ba6a 100644 (file)
@@ -20,6 +20,8 @@ export interface Ref<T = any> {
   value: T
 }
 
+export type ToRefs<T = any> = { [K in keyof T]: Ref<T[K]> }
+
 const convert = <T extends unknown>(val: T): T =>
   isObject(val) ? reactive(val) : val
 
@@ -108,9 +110,7 @@ export function customRef<T>(factory: CustomRefFactory<T>): Ref<T> {
   return r as any
 }
 
-export function toRefs<T extends object>(
-  object: T
-): { [K in keyof T]: Ref<T[K]> } {
+export function toRefs<T extends object>(object: T): ToRefs<T> {
   if (__DEV__ && !isProxy(object)) {
     console.warn(`toRefs() expects a reactive object but received a plain one.`)
   }
index 3bf99a71ebf0e09cff042b35d177719a84a34823..831e646788cfe06f753160ec4b60a58d8d6be4c0 100644 (file)
@@ -153,7 +153,8 @@ export {
   Ref,
   ComputedRef,
   UnwrapRef,
-  WritableComputedOptions
+  WritableComputedOptions,
+  ToRefs
 } from '@vue/reactivity'
 export {
   // types