From 29e09f3ce09fa889235a3edba64650cbbadb84f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=B6=E8=BF=9C=E6=96=B9?= Date: Fri, 15 Dec 2023 23:05:02 +0800 Subject: [PATCH] test(types): add test case --- types/test/v3/reactivity-test.ts | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/types/test/v3/reactivity-test.ts b/types/test/v3/reactivity-test.ts index c357bf8d5c7..7ce3b9db62c 100644 --- a/types/test/v3/reactivity-test.ts +++ b/types/test/v3/reactivity-test.ts @@ -13,9 +13,10 @@ import { markRaw, shallowReadonly, set, - del + del, + ShallowRef } from '../../index' -import { IsUnion, describe, expectType } from '../utils' +import { IsUnion, describe, expectType, expectError } from '../utils' function plainType(arg: number | Ref) { // ref coercing @@ -163,6 +164,15 @@ if (shallowStatus.value === 'initial') { shallowStatus.value = 'invalidating' } +{ + // should return ShallowRef | Ref, not ShallowRef> + expectType | Ref<{ name: string }>>( + shallowRef({} as { name: string } | Ref<{ name: string }>) + ) + expectType | Ref | ShallowRef>( + shallowRef('' as Ref | string | number) + ) +} const refStatus = ref('initial') if (refStatus.value === 'initial') { expectType>(shallowStatus) @@ -386,7 +396,6 @@ describe('set/del', () => { del([], 'fse', 123) }) - { //#12978 type Steps = { step: '1' } | { step: '2' } @@ -395,4 +404,4 @@ describe('set/del', () => { expectType>(false) expectType>(false) -} \ No newline at end of file +}