@@ -13,9 +13,10 @@ import {
13
13
markRaw ,
14
14
shallowReadonly ,
15
15
set ,
16
- del
16
+ del ,
17
+ ShallowRef
17
18
} from '../../index'
18
- import { IsUnion , describe , expectType } from '../utils'
19
+ import { IsUnion , describe , expectType , expectError } from '../utils'
19
20
20
21
function plainType ( arg : number | Ref < number > ) {
21
22
// ref coercing
@@ -163,6 +164,15 @@ if (shallowStatus.value === 'initial') {
163
164
shallowStatus . value = 'invalidating'
164
165
}
165
166
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
+ }
166
176
const refStatus = ref < Status > ( 'initial' )
167
177
if ( refStatus . value === 'initial' ) {
168
178
expectType < Ref < Status > > ( shallowStatus )
@@ -386,7 +396,6 @@ describe('set/del', () => {
386
396
del ( [ ] , 'fse' , 123 )
387
397
} )
388
398
389
-
390
399
{
391
400
//#12978
392
401
type Steps = { step : '1' } | { step : '2' }
@@ -395,4 +404,4 @@ describe('set/del', () => {
395
404
396
405
expectType < IsUnion < typeof shallowUnionGenParam > > ( false )
397
406
expectType < IsUnion < typeof shallowUnionAsCast > > ( false )
398
- }
407
+ }
0 commit comments