File tree Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Expand file tree Collapse file tree 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -244,13 +244,19 @@ expectType<typeof r1>(p1)
244
244
// proxyRefs: `ShallowUnwrapRef`
245
245
const r2 = {
246
246
a : ref ( 1 ) ,
247
+ c : computed ( ( ) => 1 ) ,
248
+ u : undefined ,
247
249
obj : {
248
250
k : ref ( 'foo' )
249
- }
251
+ } ,
252
+ union : Math . random ( ) > 0 - 5 ? ref ( { name : 'yo' } ) : null
250
253
}
251
254
const p2 = proxyRefs ( r2 )
252
255
expectType < number > ( p2 . a )
256
+ expectType < number > ( p2 . c )
257
+ expectType < undefined > ( p2 . u )
253
258
expectType < Ref < string > > ( p2 . obj . k )
259
+ expectType < { name : string } | null > ( p2 . union )
254
260
255
261
// toRef and toRefs
256
262
{
Original file line number Diff line number Diff line change @@ -476,17 +476,12 @@ type BaseTypes = string | number | boolean
476
476
*/
477
477
export interface RefUnwrapBailTypes { }
478
478
479
- type DistrubuteRef < T > = T extends Ref < infer V >
480
- ? unknown extends V
481
- ? never
482
- : V
483
- : T
484
479
export type ShallowUnwrapRef < T > = {
485
- [ K in keyof T ] : T [ K ] extends Ref < infer V >
486
- ? V // if `V` is `unknown` that means it does not extend `Ref` and is undefined
487
- : DistrubuteRef < T [ K ] >
480
+ [ K in keyof T ] : DistrubuteRef < T [ K ] >
488
481
}
489
482
483
+ type DistrubuteRef < T > = T extends Ref < infer V > ? V : T
484
+
490
485
export type UnwrapRef < T > = T extends ShallowRef < infer V >
491
486
? V
492
487
: T extends Ref < infer V >
You can’t perform that action at this time.
0 commit comments