types(reactivity): fix ref typing (#239)

This commit is contained in:
Jooger 2019-10-12 23:05:34 +08:00 committed by Evan You
parent ed5a42e588
commit 675ce2c15d

View File

@ -12,7 +12,9 @@ export interface Ref<T = any> {
const convert = (val: any): any => (isObject(val) ? reactive(val) : val) 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)) { if (isRef(raw)) {
return raw return raw
} }
@ -28,7 +30,7 @@ export function ref<T>(raw: T): Ref<T> {
trigger(v, OperationTypes.SET, '') trigger(v, OperationTypes.SET, '')
} }
} }
return v as Ref<T> return v as Ref
} }
export function isRef(v: any): v is Ref { export function isRef(v: any): v is Ref {