@@ -404,39 +404,65 @@ describe('intersect', () => {
404
404
405
405
const case1 = t . intersect ( [ 1 , Number ] )
406
406
expectTypeOf ( case1 ) . toEqualTypeOf < t . Schema <
407
- t . Schema < 1 , 1 > & t . Schema < NumberConstructor , number > ,
407
+ t . SpecialShape <
408
+ t . SpecialShapes [ 'intersection' ] , [
409
+ t . Schema < 1 , 1 > ,
410
+ t . Schema < NumberConstructor , number >
411
+ ]
412
+ > ,
408
413
1
409
414
> > ( )
410
415
expectTypeOf < t . Infer < typeof case1 > > ( )
411
416
. toEqualTypeOf < 1 > ( )
412
417
413
418
const case2 = t . intersect ( [ 1 , Number , String ] )
414
419
expectTypeOf ( case2 ) . toEqualTypeOf < t . Schema <
415
- t . Schema < 1 , 1 > & t . Schema < NumberConstructor , number > & t . Schema < StringConstructor , string > ,
420
+ t . SpecialShape <
421
+ t . SpecialShapes [ 'intersection' ] , [
422
+ t . Schema < 1 , 1 > ,
423
+ t . Schema < NumberConstructor , number > ,
424
+ t . Schema < StringConstructor , string >
425
+ ]
426
+ > ,
416
427
never
417
428
> > ( )
418
429
expectTypeOf < t . Infer < typeof case2 > > ( )
419
430
. toEqualTypeOf < never > ( )
420
431
421
432
const case3 = t . intersect ( [ Number , t . unknown ( ) ] )
422
433
expectTypeOf ( case3 ) . toEqualTypeOf < t . Schema <
423
- t . Schema < NumberConstructor , number > & t . Schema < typeof t . Symbols . unknown , unknown > ,
434
+ t . SpecialShape <
435
+ t . SpecialShapes [ 'intersection' ] , [
436
+ t . Schema < NumberConstructor , number > ,
437
+ t . Schema < typeof t . Symbols . unknown , unknown >
438
+ ]
439
+ > ,
424
440
number
425
441
> > ( )
426
442
expectTypeOf < t . Infer < typeof case3 > > ( )
427
443
. toEqualTypeOf < number > ( )
428
444
429
445
const case4 = t . intersect ( [ Number , t . never ( ) ] )
430
446
expectTypeOf ( case4 ) . toEqualTypeOf < t . Schema <
431
- t . Schema < NumberConstructor , number > & t . Schema < typeof t . Symbols . never , never > ,
447
+ t . SpecialShape <
448
+ t . SpecialShapes [ 'intersection' ] , [
449
+ t . Schema < NumberConstructor , number > ,
450
+ t . Schema < typeof t . Symbols . never , never >
451
+ ]
452
+ > ,
432
453
never
433
454
> > ( )
434
455
expectTypeOf < t . Infer < typeof case4 > > ( )
435
456
. toEqualTypeOf < never > ( )
436
457
437
458
const case5 = t . intersect ( [ Number , t . any ( ) ] )
438
459
expectTypeOf ( case5 ) . toEqualTypeOf < t . Schema <
439
- t . Schema < NumberConstructor , number > & t . Schema < any , any > ,
460
+ t . SpecialShape <
461
+ t . SpecialShapes [ 'intersection' ] , [
462
+ t . Schema < NumberConstructor , number > ,
463
+ t . Schema < any , any >
464
+ ]
465
+ > ,
440
466
any
441
467
> > ( )
442
468
expectTypeOf < t . Infer < typeof case5 > > ( )
@@ -448,14 +474,24 @@ describe('intersect', () => {
448
474
// because {} & null and {} & undefined just get tossed away.
449
475
const case6 = t . intersect ( [ Number , { } ] )
450
476
expectTypeOf ( case6 ) . toEqualTypeOf < t . Schema <
451
- t . Schema < NumberConstructor , number > & t . Schema < { } , { } > ,
477
+ t . SpecialShape <
478
+ t . SpecialShapes [ 'intersection' ] , [
479
+ t . Schema < NumberConstructor , number > ,
480
+ t . Schema < { } , { } >
481
+ ]
482
+ > ,
452
483
number
453
484
> > ( )
454
485
expectTypeOf < t . Infer < typeof case6 > > ( )
455
486
. toEqualTypeOf < number > ( )
456
487
const case7 = t . intersect ( [ Number , t ( { } ) ] )
457
488
expectTypeOf ( case7 ) . toEqualTypeOf < t . Schema <
458
- t . Schema < NumberConstructor , number > & t . Schema < { } , { } > ,
489
+ t . SpecialShape <
490
+ t . SpecialShapes [ 'intersection' ] , [
491
+ t . Schema < NumberConstructor , number > ,
492
+ t . Schema < { } , { } >
493
+ ]
494
+ > ,
459
495
number
460
496
> > ( )
461
497
expectTypeOf < t . Infer < typeof case7 > > ( )
@@ -465,12 +501,12 @@ describe('intersect', () => {
465
501
const case0 = t . union ( [ 1 , 2 , '3' ] ) . and ( String )
466
502
// ^?
467
503
expectTypeOf ( case0 ) . toEqualTypeOf < t . Schema <
468
- & (
469
- | t . Schema < 1 , 1 >
470
- | t . Schema < 2 , 2 >
471
- | t . Schema < '3' , '3' >
472
- )
473
- & t . Schema < StringConstructor , string > ,
504
+ t . SpecialShape <
505
+ t . SpecialShapes [ 'intersection' ] , [
506
+ t . Schema < 1 , 1 > | t . Schema < 2 , 2 > | t . Schema < '3' , '3' > ,
507
+ t . Schema < StringConstructor , string >
508
+ ]
509
+ > ,
474
510
'3'
475
511
> > ( )
476
512
expectTypeOf < t . Infer < typeof case0 > > ( )
@@ -517,11 +553,13 @@ describe('intersect', () => {
517
553
// `a${String}`
518
554
] )
519
555
expectTypeOf ( case0 ) . toEqualTypeOf < t . Schema <
520
- t . Schema <
521
- t . Schema < 'a' , 'a' > | t . Schema < 'ab' , 'ab' > | t . Schema < 'b' , 'b' > ,
522
- 'a' | 'ab' | 'b'
523
- > & t . Schema < `a${string } `, `a${string } `> ,
524
- ( 'a' | 'ab' | 'b' ) & `a${string } `
556
+ t . SpecialShape <
557
+ t . SpecialShapes [ 'intersection' ] , [
558
+ t . Schema < t . Schema < 'a' , 'a' > | t . Schema < 'ab' , 'ab' > | t . Schema < 'b' , 'b' > , 'a' | 'ab' | 'b' > ,
559
+ t . Schema < `a${string } `, `a${string } `>
560
+ ]
561
+ > ,
562
+ 'a' | 'ab'
525
563
> > ( )
526
564
expectTypeOf < t . Infer < typeof case0 > > ( ) . toEqualTypeOf < T0 > ( )
527
565
@@ -532,11 +570,13 @@ describe('intersect', () => {
532
570
`a${ 0 as number } `
533
571
] )
534
572
expectTypeOf ( case1 ) . toEqualTypeOf < t . Schema <
535
- t . Schema <
536
- t . Schema < 'a' , 'a' > | t . Schema < 'ax' , 'ax' > | t . Schema < 'a12' , 'a12' > | t . Schema < 'b' , 'b' > ,
537
- 'a' | 'ax' | 'a12' | 'b'
538
- > & t . Schema < `a${number } `, `a${number } `> ,
539
- ( 'a' | 'ax' | 'a12' | 'b' ) & `a${number } `
573
+ t . SpecialShape <
574
+ t . SpecialShapes [ 'intersection' ] , [
575
+ t . Schema < t . Schema < 'a' , 'a' > | t . Schema < 'ax' , 'ax' > | t . Schema < 'a12' , 'a12' > | t . Schema < 'b' , 'b' > , 'a' | 'ax' | 'a12' | 'b' > ,
576
+ t . Schema < `a${number } `, `a${number } `>
577
+ ]
578
+ > ,
579
+ 'a12'
540
580
> > ( )
541
581
expectTypeOf < t . Infer < typeof case1 > > ( ) . toEqualTypeOf < T1 > ( )
542
582
} )
0 commit comments