File tree 2 files changed +11
-2
lines changed
2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import {
18
18
computed ,
19
19
ShallowRef
20
20
} from 'vue'
21
- import { expectType , describe , IsUnion } from './utils'
21
+ import { expectType , describe , IsUnion , IsAny } from './utils'
22
22
23
23
function plainType ( arg : number | Ref < number > ) {
24
24
// ref coercing
@@ -79,6 +79,10 @@ function plainType(arg: number | Ref<number>) {
79
79
// should still unwrap in objects nested in arrays
80
80
const arr2 = ref ( [ { a : ref ( 1 ) } ] ) . value
81
81
expectType < number > ( arr2 [ 0 ] . a )
82
+
83
+ // any value should return Ref<any>, not any
84
+ const a = ref ( 1 as any )
85
+ expectType < IsAny < typeof a > > ( false )
82
86
}
83
87
84
88
plainType ( 1 )
@@ -191,6 +195,12 @@ if (refStatus.value === 'initial') {
191
195
expectType < IsUnion < typeof shallowUnionAsCast > > ( false )
192
196
}
193
197
198
+ {
199
+ // any value should return Ref<any>, not any
200
+ const a = shallowRef ( 1 as any )
201
+ expectType < IsAny < typeof a > > ( false )
202
+ }
203
+
194
204
describe ( 'shallowRef with generic' , < T > ( ) => {
195
205
const r = ref ( { } ) as MaybeRef < T >
196
206
expectType < ShallowRef < T > | Ref < T > > ( shallowRef ( r ) )
Original file line number Diff line number Diff line change @@ -87,7 +87,6 @@ export function isRef(r: any): r is Ref {
87
87
* @param value - The object to wrap in the ref.
88
88
* @see {@link https://vuejs.org/api/reactivity-core.html#ref }
89
89
*/
90
- export function ref < T extends Ref > ( value : T ) : T
91
90
export function ref < T > ( value : T ) : Ref < UnwrapRef < T > >
92
91
export function ref < T = any > ( ) : Ref < T | undefined >
93
92
export function ref ( value ?: unknown ) {
You can’t perform that action at this time.
0 commit comments