File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ export interface Ref<T = any> {
23
23
const convert = < T extends unknown > ( val : T ) : T =>
24
24
isObject ( val ) ? reactive ( val ) : val
25
25
26
- export function isRef < T > ( r : Ref < T > | T ) : r is Ref < T >
26
+ export function isRef < T > ( r : Ref < T > | unknown ) : r is Ref < T >
27
27
export function isRef ( r : any ) : r is Ref {
28
28
return r ? r . _isRef === true : false
29
29
}
30
30
31
- export function ref < T extends Ref > ( value : T ) : T
31
+ export function ref < T > ( value : T ) : T extends Ref ? T : Ref < T >
32
32
export function ref < T > ( value : T ) : Ref < T >
33
33
export function ref < T = any > ( ) : Ref < T >
34
34
export function ref ( value ?: unknown ) {
Original file line number Diff line number Diff line change
1
+ import { expectType } from 'tsd'
2
+ import { Ref , ref } from './index'
3
+ import { isRef } from '@vue/reactivity'
4
+
5
+ function foo ( arg : number | Ref < number > ) {
6
+ // ref coercing
7
+ const coerced = ref ( arg )
8
+ expectType < Ref < number > > ( coerced )
9
+
10
+ // isRef as type guard
11
+ if ( isRef ( arg ) ) {
12
+ expectType < Ref < number > > ( arg )
13
+ }
14
+ }
15
+
16
+ foo ( 1 )
You can’t perform that action at this time.
0 commit comments