@@ -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
2021function plainType ( arg : number | Ref < number > ) {
2122 // ref coercing
@@ -163,6 +164,15 @@ if (shallowStatus.value === 'initial') {
163164 shallowStatus . value = 'invalidating'
164165}
165166
167+ {
168+ // should return ShallowRef<T> | Ref<T>, not ShallowRef<T | Ref<T>>
169+ expectType < ShallowRef < { name : string } > | Ref < { name : string } > > (
170+ shallowRef ( { } as { name : string } | Ref < { name : string } > )
171+ )
172+ expectType < ShallowRef < number > | Ref < string [ ] > | ShallowRef < string > > (
173+ shallowRef ( '' as Ref < string [ ] > | string | number )
174+ )
175+ }
166176const refStatus = ref < Status > ( 'initial' )
167177if ( refStatus . value === 'initial' ) {
168178 expectType < Ref < Status > > ( shallowStatus )
@@ -386,7 +396,6 @@ describe('set/del', () => {
386396 del ( [ ] , 'fse' , 123 )
387397} )
388398
389-
390399{
391400 //#12978
392401 type Steps = { step : '1' } | { step : '2' }
@@ -395,4 +404,4 @@ describe('set/del', () => {
395404
396405 expectType < IsUnion < typeof shallowUnionGenParam > > ( false )
397406 expectType < IsUnion < typeof shallowUnionAsCast > > ( false )
398- }
407+ }
0 commit comments