@@ -393,6 +393,24 @@ describe('Utils', () => {
393
393
394
394
expect ( result . _unsafeUnwrap ( ) ) . toEqual ( [ 'Yooooo' , 123 , true ] )
395
395
} )
396
+
397
+ it ( 'Does not destructure / concatenate arrays' , ( ) => {
398
+ type HomogenousList = [
399
+ Result < string [ ] , boolean > ,
400
+ Result < number [ ] , string > ,
401
+ ]
402
+
403
+ const homogenousList : HomogenousList = [
404
+ ok ( [ 'hello' , 'world' ] ) ,
405
+ ok ( [ 1 , 2 , 3 ] )
406
+ ]
407
+
408
+ type ExpectedResult = Result < [ string [ ] , number [ ] ] , boolean | string >
409
+
410
+ const result : ExpectedResult = combine ( homogenousList )
411
+
412
+ expect ( result . _unsafeUnwrap ( ) ) . toEqual ( [ [ 'hello' , 'world' ] , [ 1 , 2 , 3 ] ] )
413
+ } )
396
414
} )
397
415
398
416
describe ( 'Async `combine`' , ( ) => {
@@ -424,19 +442,25 @@ describe('Utils', () => {
424
442
} )
425
443
426
444
it ( 'Combines heterogeneous lists' , async ( ) => {
427
- type HeterogenousList = [ ResultAsync < string , string > , ResultAsync < number , number > , ResultAsync < boolean , boolean > ]
445
+ type HeterogenousList = [
446
+ ResultAsync < string , string > ,
447
+ ResultAsync < number , number > ,
448
+ ResultAsync < boolean , boolean > ,
449
+ ResultAsync < number [ ] , string > ,
450
+ ]
428
451
429
452
const heterogenousList : HeterogenousList = [
430
453
okAsync ( 'Yooooo' ) ,
431
454
okAsync ( 123 ) ,
432
455
okAsync ( true ) ,
456
+ okAsync ( [ 1 , 2 , 3 ] ) ,
433
457
]
434
458
435
- type ExpecteResult = Result < [ string , number , boolean ] , string | number | boolean >
459
+ type ExpecteResult = Result < [ string , number , boolean , number [ ] ] , string | number | boolean >
436
460
437
- const result : ExpecteResult = await combine ( heterogenousList )
461
+ const result : ExpecteResult = await combine ( heterogenousList )
438
462
439
- expect ( result . _unsafeUnwrap ( ) ) . toEqual ( [ 'Yooooo' , 123 , true ] )
463
+ expect ( result . _unsafeUnwrap ( ) ) . toEqual ( [ 'Yooooo' , 123 , true , [ 1 , 2 , 3 ] ] )
440
464
} )
441
465
} )
442
466
} )
0 commit comments