types(reactivity): fix ref typing (#239)
This commit is contained in:
		
							parent
							
								
									ed5a42e588
								
							
						
					
					
						commit
						675ce2c15d
					
				| @ -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 { | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user