]> git.ipfire.org Git - thirdparty/vuejs/core.git/commitdiff
types(reactivity): fix ref typing (#239)
authorJooger <iamjooger@gmail.com>
Sat, 12 Oct 2019 15:05:34 +0000 (23:05 +0800)
committerEvan You <yyx990803@gmail.com>
Sat, 12 Oct 2019 15:05:34 +0000 (11:05 -0400)
packages/reactivity/src/ref.ts

index 3616799e3643dd02db13542b42f49226c8bbaa36..234a638b7923f187cefcd532d190be637212fa58 100644 (file)
@@ -12,7 +12,9 @@ export interface Ref<T = any> {
 
 const convert = (val: any): any => (isObject(val) ? reactive(val) : val)
 
-export function ref<T>(raw: T): Ref<T> {
+export function ref<T extends Ref>(raw: T): T
+export function ref<T>(raw: T): Ref<T>
+export function ref(raw: any) {
   if (isRef(raw)) {
     return raw
   }
@@ -28,7 +30,7 @@ export function ref<T>(raw: T): Ref<T> {
       trigger(v, OperationTypes.SET, '')
     }
   }
-  return v as Ref<T>
+  return v as Ref
 }
 
 export function isRef(v: any): v is Ref {