Skip to content

Commit 611cb26

Browse files
committedDec 15, 2023
test(types): add test case
1 parent 7da94ea commit 611cb26

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed
 

‎types/test/v3/reactivity-test.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import {
1313
markRaw,
1414
shallowReadonly,
1515
set,
16-
del
16+
del,
17+
ShallowRef
1718
} from '../../index'
18-
import { IsUnion, describe, expectType } from '../utils'
19+
import { IsUnion, describe, expectType, expectError } from '../utils'
1920

2021
function plainType(arg: number | Ref<number>) {
2122
// ref coercing
@@ -163,6 +164,13 @@ if (shallowStatus.value === 'initial') {
163164
shallowStatus.value = 'invalidating'
164165
}
165166

167+
expectType<ShallowRef<number>>(shallowRef(1))
168+
expectType<ShallowRef<{ name: string } | Ref<{ name: string }>>>(
169+
shallowRef({} as { name: string } | Ref<{ name: string }>)
170+
)
171+
expectType<Ref<string>>(shallowRef(ref('foo')))
172+
expectType<ShallowRef<string>>(shallowRef(shallowRef('foo')))
173+
166174
const refStatus = ref<Status>('initial')
167175
if (refStatus.value === 'initial') {
168176
expectType<Ref<Status>>(shallowStatus)
@@ -386,7 +394,6 @@ describe('set/del', () => {
386394
del([], 'fse', 123)
387395
})
388396

389-
390397
{
391398
//#12978
392399
type Steps = { step: '1' } | { step: '2' }
@@ -395,4 +402,4 @@ describe('set/del', () => {
395402

396403
expectType<IsUnion<typeof shallowUnionGenParam>>(false)
397404
expectType<IsUnion<typeof shallowUnionAsCast>>(false)
398-
}
405+
}

0 commit comments

Comments
 (0)
Failed to load comments.