Skip to content

Commit

Permalink
test(types): add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Alfred-Skyblue committed Dec 15, 2023
1 parent 7da94ea commit 29e09f3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions types/test/v3/reactivity-test.ts
Expand Up @@ -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<number>) {
// ref coercing
Expand Down Expand Up @@ -163,6 +164,15 @@ if (shallowStatus.value === 'initial') {
shallowStatus.value = 'invalidating'
}

{
// should return ShallowRef<T> | Ref<T>, not ShallowRef<T | Ref<T>>
expectType<ShallowRef<{ name: string }> | Ref<{ name: string }>>(
shallowRef({} as { name: string } | Ref<{ name: string }>)
)
expectType<ShallowRef<number> | Ref<string[]> | ShallowRef<string>>(
shallowRef('' as Ref<string[]> | string | number)
)
}
const refStatus = ref<Status>('initial')
if (refStatus.value === 'initial') {
expectType<Ref<Status>>(shallowStatus)
Expand Down Expand Up @@ -386,7 +396,6 @@ describe('set/del', () => {
del([], 'fse', 123)
})


{
//#12978
type Steps = { step: '1' } | { step: '2' }
Expand All @@ -395,4 +404,4 @@ describe('set/del', () => {

expectType<IsUnion<typeof shallowUnionGenParam>>(false)
expectType<IsUnion<typeof shallowUnionAsCast>>(false)
}
}

0 comments on commit 29e09f3

Please sign in to comment.