|
@@ -18,7 +18,7 @@ import {
|
|
|
computed,
|
|
computed,
|
|
|
ShallowRef
|
|
ShallowRef
|
|
|
} from 'vue'
|
|
} from 'vue'
|
|
|
-import { expectType, describe, IsUnion } from './utils'
|
|
|
|
|
|
|
+import { expectType, describe, IsUnion, IsAny } from './utils'
|
|
|
|
|
|
|
|
function plainType(arg: number | Ref<number>) {
|
|
function plainType(arg: number | Ref<number>) {
|
|
|
// ref coercing
|
|
// ref coercing
|
|
@@ -79,6 +79,10 @@ function plainType(arg: number | Ref<number>) {
|
|
|
// should still unwrap in objects nested in arrays
|
|
// should still unwrap in objects nested in arrays
|
|
|
const arr2 = ref([{ a: ref(1) }]).value
|
|
const arr2 = ref([{ a: ref(1) }]).value
|
|
|
expectType<number>(arr2[0].a)
|
|
expectType<number>(arr2[0].a)
|
|
|
|
|
+
|
|
|
|
|
+ // any value should return Ref<any>, not any
|
|
|
|
|
+ const a = ref(1 as any)
|
|
|
|
|
+ expectType<IsAny<typeof a>>(false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
plainType(1)
|
|
plainType(1)
|
|
@@ -191,6 +195,12 @@ if (refStatus.value === 'initial') {
|
|
|
expectType<IsUnion<typeof shallowUnionAsCast>>(false)
|
|
expectType<IsUnion<typeof shallowUnionAsCast>>(false)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+{
|
|
|
|
|
+ // any value should return Ref<any>, not any
|
|
|
|
|
+ const a = shallowRef(1 as any)
|
|
|
|
|
+ expectType<IsAny<typeof a>>(false)
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
describe('shallowRef with generic', <T>() => {
|
|
describe('shallowRef with generic', <T>() => {
|
|
|
const r = ref({}) as MaybeRef<T>
|
|
const r = ref({}) as MaybeRef<T>
|
|
|
expectType<ShallowRef<T> | Ref<T>>(shallowRef(r))
|
|
expectType<ShallowRef<T> | Ref<T>>(shallowRef(r))
|