@@ -16,7 +16,7 @@ import {
16
16
MaybeRefOrGetter ,
17
17
ComputedRef ,
18
18
computed ,
19
- ShallowRef
19
+ ShallowRef ,
20
20
} from 'vue'
21
21
import { expectType , describe , IsUnion , IsAny } from './utils'
22
22
@@ -37,7 +37,7 @@ function plainType(arg: number | Ref<number>) {
37
37
38
38
// ref inner type should be unwrapped
39
39
const nestedRef = ref ( {
40
- foo : ref ( 1 )
40
+ foo : ref ( 1 ) ,
41
41
} )
42
42
expectType < { foo : number } > ( nestedRef . value )
43
43
@@ -60,7 +60,7 @@ function plainType(arg: number | Ref<number>) {
60
60
61
61
// with symbol
62
62
expectType < Ref < IteratorFoo | null | undefined > > (
63
- ref < IteratorFoo | null | undefined > ( )
63
+ ref < IteratorFoo | null | undefined > ( ) ,
64
64
)
65
65
66
66
// should not unwrap ref inside arrays
@@ -101,13 +101,11 @@ function bailType(arg: HTMLElement | Ref<HTMLElement>) {
101
101
expectType < HTMLElement > ( unref ( arg ) )
102
102
103
103
// ref inner type should be unwrapped
104
- // eslint-disable-next-line no-restricted-globals
105
104
const nestedRef = ref ( { foo : ref ( document . createElement ( 'DIV' ) ) } )
106
105
107
106
expectType < Ref < { foo : HTMLElement } > > ( nestedRef )
108
107
expectType < { foo : HTMLElement } > ( nestedRef . value )
109
108
}
110
- // eslint-disable-next-line no-restricted-globals
111
109
const el = document . createElement ( 'DIV' )
112
110
bailType ( el )
113
111
@@ -127,7 +125,7 @@ function withSymbol() {
127
125
[ Symbol . toPrimitive ] : new WeakMap < Ref < boolean > , string > ( ) ,
128
126
[ Symbol . toStringTag ] : { weakSet : new WeakSet < Ref < boolean > > ( ) } ,
129
127
[ Symbol . unscopables ] : { weakMap : new WeakMap < Ref < boolean > , string > ( ) } ,
130
- [ customSymbol ] : { arr : [ ref ( 1 ) ] }
128
+ [ customSymbol ] : { arr : [ ref ( 1 ) ] } ,
131
129
}
132
130
133
131
const objRef = ref ( obj )
@@ -144,10 +142,10 @@ function withSymbol() {
144
142
expectType < WeakSet < Ref < boolean > > > ( objRef . value [ Symbol . split ] )
145
143
expectType < WeakMap < Ref < boolean > , string > > ( objRef . value [ Symbol . toPrimitive ] )
146
144
expectType < { weakSet : WeakSet < Ref < boolean > > } > (
147
- objRef . value [ Symbol . toStringTag ]
145
+ objRef . value [ Symbol . toStringTag ] ,
148
146
)
149
147
expectType < { weakMap : WeakMap < Ref < boolean > , string > } > (
150
- objRef . value [ Symbol . unscopables ]
148
+ objRef . value [ Symbol . unscopables ] ,
151
149
)
152
150
expectType < { arr : Ref < number > [ ] } > ( objRef . value [ customSymbol ] )
153
151
}
@@ -157,8 +155,8 @@ withSymbol()
157
155
const state = reactive ( {
158
156
foo : {
159
157
value : 1 ,
160
- label : 'bar'
161
- }
158
+ label : 'bar' ,
159
+ } ,
162
160
} )
163
161
164
162
expectType < string > ( state . foo . label )
@@ -227,16 +225,16 @@ describe('shallowRef with generic', <T extends { name: string }>() => {
227
225
{
228
226
// should return ShallowRef<T> | Ref<T>, not ShallowRef<T | Ref<T>>
229
227
expectType < ShallowRef < { name : string } > | Ref < { name : string } > > (
230
- shallowRef ( { } as MaybeRef < { name : string } > )
228
+ shallowRef ( { } as MaybeRef < { name : string } > ) ,
231
229
)
232
230
expectType < ShallowRef < number > | Ref < string [ ] > | ShallowRef < string > > (
233
- shallowRef ( '' as Ref < string [ ] > | string | number )
231
+ shallowRef ( '' as Ref < string [ ] > | string | number ) ,
234
232
)
235
233
}
236
234
237
235
// proxyRefs: should return `reactive` directly
238
236
const r1 = reactive ( {
239
- k : 'v'
237
+ k : 'v' ,
240
238
} )
241
239
const p1 = proxyRefs ( r1 )
242
240
expectType < typeof r1 > ( p1 )
@@ -245,8 +243,8 @@ expectType<typeof r1>(p1)
245
243
const r2 = {
246
244
a : ref ( 1 ) ,
247
245
obj : {
248
- k : ref ( 'foo' )
249
- }
246
+ k : ref ( 'foo' ) ,
247
+ } ,
250
248
}
251
249
const p2 = proxyRefs ( r2 )
252
250
expectType < number > ( p2 . a )
@@ -261,7 +259,7 @@ expectType<Ref<string>>(p2.obj.k)
261
259
} = {
262
260
a : 1 ,
263
261
b : ref ( 1 ) ,
264
- c : 1
262
+ c : 1 ,
265
263
}
266
264
267
265
// toRef
@@ -288,8 +286,8 @@ expectType<Ref<string>>(p2.obj.k)
288
286
// Both should not do any unwrapping
289
287
const someReactive = shallowReactive ( {
290
288
a : {
291
- b : ref ( 42 )
292
- }
289
+ b : ref ( 42 ) ,
290
+ } ,
293
291
} )
294
292
295
293
const toRefResult = toRef ( someReactive , 'a' )
@@ -321,8 +319,8 @@ interface AppData {
321
319
322
320
const data : ToRefs < AppData > = toRefs (
323
321
reactive ( {
324
- state : 'state1'
325
- } )
322
+ state : 'state1' ,
323
+ } ) ,
326
324
)
327
325
328
326
switch ( data . state . value ) {
@@ -349,9 +347,9 @@ describe('shallow reactive in reactive', () => {
349
347
const baz = reactive ( {
350
348
foo : shallowReactive ( {
351
349
a : {
352
- b : ref ( 42 )
353
- }
354
- } )
350
+ b : ref ( 42 ) ,
351
+ } ,
352
+ } ) ,
355
353
} )
356
354
357
355
const foo = toRef ( baz , 'foo' )
@@ -366,10 +364,10 @@ describe('shallow ref in reactive', () => {
366
364
bar : {
367
365
baz : ref ( 123 ) ,
368
366
qux : reactive ( {
369
- z : ref ( 123 )
370
- } )
371
- }
372
- } )
367
+ z : ref ( 123 ) ,
368
+ } ) ,
369
+ } ,
370
+ } ) ,
373
371
} )
374
372
375
373
expectType < Ref < number > > ( x . foo . bar . baz )
@@ -378,7 +376,7 @@ describe('shallow ref in reactive', () => {
378
376
379
377
describe ( 'ref in shallow ref' , ( ) => {
380
378
const x = shallowRef ( {
381
- a : ref ( 123 )
379
+ a : ref ( 123 ) ,
382
380
} )
383
381
384
382
expectType < Ref < number > > ( x . value . a )
@@ -387,8 +385,8 @@ describe('ref in shallow ref', () => {
387
385
describe ( 'reactive in shallow ref' , ( ) => {
388
386
const x = shallowRef ( {
389
387
a : reactive ( {
390
- b : ref ( 0 )
391
- } )
388
+ b : ref ( 0 ) ,
389
+ } ) ,
392
390
} )
393
391
394
392
expectType < number > ( x . value . a . b )
@@ -399,7 +397,7 @@ describe('toRef <-> toValue', () => {
399
397
a : MaybeRef < string > ,
400
398
b : ( ) => string ,
401
399
c : MaybeRefOrGetter < string > ,
402
- d : ComputedRef < string >
400
+ d : ComputedRef < string > ,
403
401
) {
404
402
const r = toRef ( a )
405
403
expectType < Ref < string > > ( r )
@@ -430,7 +428,7 @@ describe('toRef <-> toValue', () => {
430
428
r : toValue ( r ) ,
431
429
rb : toValue ( rb ) ,
432
430
rc : toValue ( rc ) ,
433
- rd : toValue ( rd )
431
+ rd : toValue ( rd ) ,
434
432
}
435
433
}
436
434
@@ -444,7 +442,7 @@ describe('toRef <-> toValue', () => {
444
442
'foo' ,
445
443
( ) => 'bar' ,
446
444
ref ( 'baz' ) ,
447
- computed ( ( ) => 'hi' )
448
- )
445
+ computed ( ( ) => 'hi' ) ,
446
+ ) ,
449
447
)
450
448
} )
0 commit comments