|
|
@@ -15,9 +15,10 @@ import {
|
|
|
MaybeRef,
|
|
|
MaybeRefOrGetter,
|
|
|
ComputedRef,
|
|
|
- computed
|
|
|
+ computed,
|
|
|
+ ShallowRef
|
|
|
} from 'vue'
|
|
|
-import { expectType, describe } from './utils'
|
|
|
+import { expectType, describe, IsUnion } from './utils'
|
|
|
|
|
|
function plainType(arg: number | Ref<number>) {
|
|
|
// ref coercing
|
|
|
@@ -174,6 +175,27 @@ if (refStatus.value === 'initial') {
|
|
|
refStatus.value = 'invalidating'
|
|
|
}
|
|
|
|
|
|
+{
|
|
|
+ const shallow = shallowRef(1)
|
|
|
+ expectType<Ref<number>>(shallow)
|
|
|
+ expectType<ShallowRef<number>>(shallow)
|
|
|
+}
|
|
|
+
|
|
|
+{
|
|
|
+ //#7852
|
|
|
+ type Steps = { step: '1' } | { step: '2' }
|
|
|
+ const shallowUnionGenParam = shallowRef<Steps>({ step: '1' })
|
|
|
+ const shallowUnionAsCast = shallowRef({ step: '1' } as Steps)
|
|
|
+
|
|
|
+ expectType<IsUnion<typeof shallowUnionGenParam>>(false)
|
|
|
+ expectType<IsUnion<typeof shallowUnionAsCast>>(false)
|
|
|
+}
|
|
|
+
|
|
|
+describe('shallowRef with generic', <T>() => {
|
|
|
+ const r = ref({}) as MaybeRef<T>
|
|
|
+ expectType<ShallowRef<T> | Ref<T>>(shallowRef(r))
|
|
|
+})
|
|
|
+
|
|
|
// proxyRefs: should return `reactive` directly
|
|
|
const r1 = reactive({
|
|
|
k: 'v'
|