File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ import {
1818 computed ,
1919 ShallowRef
2020} from 'vue'
21- import { expectType , describe , IsUnion } from './utils'
21+ import { expectType , describe , IsUnion , IsAny } from './utils'
2222
2323function plainType ( arg : number | Ref < number > ) {
2424 // ref coercing
@@ -79,6 +79,10 @@ function plainType(arg: number | Ref<number>) {
7979 // should still unwrap in objects nested in arrays
8080 const arr2 = ref ( [ { a : ref ( 1 ) } ] ) . value
8181 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 )
8286}
8387
8488plainType ( 1 )
@@ -191,6 +195,12 @@ if (refStatus.value === 'initial') {
191195 expectType < IsUnion < typeof shallowUnionAsCast > > ( false )
192196}
193197
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+
194204describe ( 'shallowRef with generic' , < T > ( ) => {
195205 const r = ref ( { } ) as MaybeRef < T >
196206 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 {
8787 * @param value - The object to wrap in the ref.
8888 * @see {@link https://vuejs.org/api/reactivity-core.html#ref }
8989 */
90- export function ref < T extends Ref > ( value : T ) : T
9190export function ref < T > ( value : T ) : Ref < UnwrapRef < T > >
9291export function ref < T = any > ( ) : Ref < T | undefined >
9392export function ref ( value ?: unknown ) {
You can’t perform that action at this time.
0 commit comments