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 611cb26
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 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,13 @@ if (shallowStatus.value === 'initial') {
shallowStatus.value = 'invalidating'
}

expectType<ShallowRef<number>>(shallowRef(1))
expectType<ShallowRef<{ name: string } | Ref<{ name: string }>>>(
shallowRef({} as { name: string } | Ref<{ name: string }>)
)
expectType<Ref<string>>(shallowRef(ref('foo')))
expectType<ShallowRef<string>>(shallowRef(shallowRef('foo')))

const refStatus = ref<Status>('initial')
if (refStatus.value === 'initial') {
expectType<Ref<Status>>(shallowStatus)
Expand Down Expand Up @@ -386,7 +394,6 @@ describe('set/del', () => {
del([], 'fse', 123)
})


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

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

0 comments on commit 611cb26

Please sign in to comment.