55import {
66 assertSnapshot ,
77} from "https://deno.land/[email protected] /testing/snapshot.ts" ; 8- import type {
9- AssertTrue ,
10- IsExact ,
8+ import {
9+ assertType ,
10+ type IsExact ,
1111} from "https://deno.land/[email protected] /testing/types.ts" ; 1212import is , {
1313 isAllOf ,
@@ -111,16 +111,13 @@ Deno.test("PredicateType", () => {
111111 } ) ,
112112 ] ) ) ,
113113 } ) ;
114- type _ = AssertTrue <
115- IsExact <
116- PredicateType < typeof isArticle > ,
117- {
118- title : string ;
119- body : string ;
120- refs : ( string | { name : string ; url : string } ) [ ] ;
121- }
122- >
123- > ;
114+ assertType <
115+ IsExact < PredicateType < typeof isArticle > , {
116+ title : string ;
117+ body : string ;
118+ refs : ( string | { name : string ; url : string } ) [ ] ;
119+ } >
120+ > ( true ) ;
124121} ) ;
125122
126123Deno . test ( "isAny" , async ( t ) => {
@@ -191,7 +188,7 @@ Deno.test("isArrayOf<T>", async (t) => {
191188 await t . step ( "returns proper type predicate" , ( ) => {
192189 const a : unknown = [ 0 , 1 , 2 ] ;
193190 if ( isArrayOf ( isNumber ) ( a ) ) {
194- type _ = AssertTrue < IsExact < typeof a , number [ ] > > ;
191+ assertType < IsExact < typeof a , number [ ] > > ( true ) ;
195192 }
196193 } ) ;
197194 await t . step ( "returns true on T array" , ( ) => {
@@ -210,21 +207,21 @@ Deno.test("isArrayOf<T>", async (t) => {
210207} ) ;
211208
212209Deno . test ( "TupleOf<T>" , ( ) => {
213- type _ = AssertTrue <
210+ assertType <
214211 IsExact <
215212 TupleOf < readonly [ typeof is . String , typeof is . Number ] > ,
216213 [ string , number ]
217214 >
218- > ;
215+ > ( true ) ;
219216} ) ;
220217
221218Deno . test ( "ReadonlyTupleOf<T>" , ( ) => {
222- type _ = AssertTrue <
219+ assertType <
223220 IsExact <
224221 ReadonlyTupleOf < readonly [ typeof is . String , typeof is . Number ] > ,
225222 readonly [ string , number ]
226223 >
227- > ;
224+ > ( true ) ;
228225} ) ;
229226
230227Deno . test ( "isTupleOf<T>" , async ( t ) => {
@@ -251,9 +248,7 @@ Deno.test("isTupleOf<T>", async (t) => {
251248 const predTup = [ isNumber , isString , isBoolean ] as const ;
252249 const a : unknown = [ 0 , "a" , true ] ;
253250 if ( isTupleOf ( predTup ) ( a ) ) {
254- type _ = AssertTrue <
255- IsExact < typeof a , [ number , string , boolean ] >
256- > ;
251+ assertType < IsExact < typeof a , [ number , string , boolean ] > > ( true ) ;
257252 }
258253 } ) ;
259254 await t . step ( "returns true on T tuple" , ( ) => {
@@ -309,9 +304,9 @@ Deno.test("isTupleOf<T, E>", async (t) => {
309304 const predElse = is . ArrayOf ( is . Number ) ;
310305 const a : unknown = [ 0 , "a" , true , 0 , 1 , 2 ] ;
311306 if ( isTupleOf ( predTup , predElse ) ( a ) ) {
312- type _ = AssertTrue <
313- IsExact < typeof a , [ number , string , boolean , ... number [ ] ] >
314- > ;
307+ assertType < IsExact < typeof a , [ number , string , boolean , ... number [ ] ] > > (
308+ true ,
309+ ) ;
315310 }
316311 } ) ;
317312 await t . step ( "returns true on T tuple" , ( ) => {
@@ -379,9 +374,7 @@ Deno.test("isReadonlyTupleOf<T>", async (t) => {
379374 const predTup = [ isNumber , isString , isBoolean ] as const ;
380375 const a : unknown = [ 0 , "a" , true ] ;
381376 if ( isReadonlyTupleOf ( predTup ) ( a ) ) {
382- type _ = AssertTrue <
383- IsExact < typeof a , readonly [ number , string , boolean ] >
384- > ;
377+ assertType < IsExact < typeof a , readonly [ number , string , boolean ] > > ( true ) ;
385378 }
386379 } ) ;
387380 await t . step ( "returns true on T tuple" , ( ) => {
@@ -447,9 +440,9 @@ Deno.test("isReadonlyTupleOf<T, E>", async (t) => {
447440 const predElse = is . ArrayOf ( is . Number ) ;
448441 const a : unknown = [ 0 , "a" , true , 0 , 1 , 2 ] ;
449442 if ( isReadonlyTupleOf ( predTup , predElse ) ( a ) ) {
450- type _ = AssertTrue <
443+ assertType <
451444 IsExact < typeof a , readonly [ number , string , boolean , ...number [ ] ] >
452- > ;
445+ > ( true ) ;
453446 }
454447 } ) ;
455448 await t . step ( "returns true on T tuple" , ( ) => {
@@ -501,21 +494,24 @@ Deno.test("isReadonlyTupleOf<T, E>", async (t) => {
501494} ) ;
502495
503496Deno . test ( "UniformTupleOf<N, T>" , ( ) => {
504- type _ = AssertTrue <
505- IsExact <
506- UniformTupleOf < number , 5 > ,
507- [ number , number , number , number , number ]
508- >
509- > ;
497+ assertType <
498+ IsExact < UniformTupleOf < number , 5 > , [ number , number , number , number , number ] >
499+ > ( true ) ;
510500} ) ;
511501
512502Deno . test ( "ReadonlyUniformTupleOf<N, T>" , ( ) => {
513- type _ = AssertTrue <
503+ assertType <
514504 IsExact <
515505 ReadonlyUniformTupleOf < number , 5 > ,
516- readonly [ number , number , number , number , number ]
506+ readonly [
507+ number ,
508+ number ,
509+ number ,
510+ number ,
511+ number ,
512+ ]
517513 >
518- > ;
514+ > ( true ) ;
519515} ) ;
520516
521517Deno . test ( "isUniformTupleOf<T>" , async ( t ) => {
@@ -530,18 +526,15 @@ Deno.test("isUniformTupleOf<T>", async (t) => {
530526 await t . step ( "returns proper type predicate" , ( ) => {
531527 const a : unknown = [ 0 , 1 , 2 , 3 , 4 ] ;
532528 if ( isUniformTupleOf ( 5 ) ( a ) ) {
533- type _ = AssertTrue <
534- IsExact <
535- typeof a ,
536- [ unknown , unknown , unknown , unknown , unknown ]
537- >
538- > ;
529+ assertType <
530+ IsExact < typeof a , [ unknown , unknown , unknown , unknown , unknown ] >
531+ > ( true ) ;
539532 }
540533
541534 if ( isUniformTupleOf ( 5 , isNumber ) ( a ) ) {
542- type _ = AssertTrue <
543- IsExact < typeof a , [ number , number , number , number , number ] >
544- > ;
535+ assertType < IsExact < typeof a , [ number , number , number , number , number ] > > (
536+ true ,
537+ ) ;
545538 }
546539 } ) ;
547540 await t . step ( "returns true on mono-typed T tuple" , ( ) => {
@@ -570,18 +563,18 @@ Deno.test("isReadonlyUniformTupleOf<T>", async (t) => {
570563 await t . step ( "returns proper type predicate" , ( ) => {
571564 const a : unknown = [ 0 , 1 , 2 , 3 , 4 ] ;
572565 if ( isReadonlyUniformTupleOf ( 5 ) ( a ) ) {
573- type _ = AssertTrue <
566+ assertType <
574567 IsExact <
575568 typeof a ,
576569 readonly [ unknown , unknown , unknown , unknown , unknown ]
577570 >
578- > ;
571+ > ( true ) ;
579572 }
580573
581574 if ( isReadonlyUniformTupleOf ( 5 , isNumber ) ( a ) ) {
582- type _ = AssertTrue <
575+ assertType <
583576 IsExact < typeof a , readonly [ number , number , number , number , number ] >
584- > ;
577+ > ( true ) ;
585578 }
586579 } ) ;
587580 await t . step ( "returns true on mono-typed T tuple" , ( ) => {
@@ -615,9 +608,7 @@ Deno.test("isRecordOf<T>", async (t) => {
615608 await t . step ( "returns proper type predicate" , ( ) => {
616609 const a : unknown = { a : 0 } ;
617610 if ( isRecordOf ( isNumber ) ( a ) ) {
618- type _ = AssertTrue <
619- IsExact < typeof a , Record < PropertyKey , number > >
620- > ;
611+ assertType < IsExact < typeof a , Record < PropertyKey , number > > > ( true ) ;
621612 }
622613 } ) ;
623614 await t . step ( "returns true on T record" , ( ) => {
@@ -646,9 +637,7 @@ Deno.test("isRecordOf<T, K>", async (t) => {
646637 await t . step ( "returns proper type predicate" , ( ) => {
647638 const a : unknown = { a : 0 } ;
648639 if ( isRecordOf ( isNumber , isString ) ( a ) ) {
649- type _ = AssertTrue <
650- IsExact < typeof a , Record < string , number > >
651- > ;
640+ assertType < IsExact < typeof a , Record < string , number > > > ( true ) ;
652641 }
653642 } ) ;
654643 await t . step ( "returns true on T record" , ( ) => {
@@ -672,12 +661,12 @@ Deno.test("isRecordOf<T, K>", async (t) => {
672661} ) ;
673662
674663Deno . test ( "ObjectOf<T>" , ( ) => {
675- type _ = AssertTrue <
664+ assertType <
676665 IsExact <
677666 ObjectOf < { a : typeof is . Number ; b : typeof is . String } > ,
678667 { a : number ; b : string }
679668 >
680- > ;
669+ > ( true ) ;
681670} ) ;
682671
683672Deno . test ( "isObjectOf<T>" , async ( t ) => {
@@ -704,9 +693,7 @@ Deno.test("isObjectOf<T>", async (t) => {
704693 } ;
705694 const a : unknown = { a : 0 , b : "a" , c : true } ;
706695 if ( isObjectOf ( predObj ) ( a ) ) {
707- type _ = AssertTrue <
708- IsExact < typeof a , { a : number ; b : string ; c : boolean } >
709- > ;
696+ assertType < IsExact < typeof a , { a : number ; b : string ; c : boolean } > > ( true ) ;
710697 }
711698 } ) ;
712699 await t . step ( "returns true on T object" , ( ) => {
@@ -769,9 +756,9 @@ Deno.test("isObjectOf<T>", async (t) => {
769756 } ;
770757 const a : unknown = { a : 0 , b : "a" } ;
771758 if ( isObjectOf ( predObj ) ( a ) ) {
772- type _ = AssertTrue <
759+ assertType <
773760 IsExact < typeof a , { a : number ; b : string | undefined ; c ?: boolean } >
774- > ;
761+ > ( true ) ;
775762 }
776763 } ) ;
777764 await t . step ( "returns true on T object" , ( ) => {
@@ -845,33 +832,33 @@ Deno.test("isFunction", async (t) => {
845832 await testWithExamples ( t , isFunction , {
846833 validExamples : [ "syncFunction" , "asyncFunction" ] ,
847834 } ) ;
848- type _ = AssertTrue <
835+ assertType <
849836 IsExact < PredicateType < typeof isFunction > , ( ...args : unknown [ ] ) => unknown >
850- > ;
837+ > ( true ) ;
851838} ) ;
852839
853840Deno . test ( "isSyncFunction" , async ( t ) => {
854841 await testWithExamples ( t , isSyncFunction , {
855842 validExamples : [ "syncFunction" ] ,
856843 } ) ;
857- type _ = AssertTrue <
844+ assertType <
858845 IsExact <
859846 PredicateType < typeof isSyncFunction > ,
860847 ( ...args : unknown [ ] ) => unknown
861848 >
862- > ;
849+ > ( true ) ;
863850} ) ;
864851
865852Deno . test ( "isAsyncFunction" , async ( t ) => {
866853 await testWithExamples ( t , isAsyncFunction , {
867854 validExamples : [ "asyncFunction" ] ,
868855 } ) ;
869- type _ = AssertTrue <
856+ assertType <
870857 IsExact <
871858 PredicateType < typeof isAsyncFunction > ,
872859 ( ...args : unknown [ ] ) => Promise < unknown >
873860 >
874- > ;
861+ > ( true ) ;
875862} ) ;
876863
877864Deno . test ( "isInstanceOf<T>" , async ( t ) => {
@@ -901,17 +888,17 @@ Deno.test("isInstanceOf<T>", async (t) => {
901888 class Cls { }
902889 const a : unknown = new Cls ( ) ;
903890 if ( isInstanceOf ( Cls ) ( a ) ) {
904- type _ = AssertTrue < IsExact < typeof a , Cls > > ;
891+ assertType < IsExact < typeof a , Cls > > ( true ) ;
905892 }
906893
907894 const b : unknown = new Date ( ) ;
908895 if ( isInstanceOf ( Date ) ( b ) ) {
909- type _ = AssertTrue < IsExact < typeof b , Date > > ;
896+ assertType < IsExact < typeof b , Date > > ( true ) ;
910897 }
911898
912899 const c : unknown = new Promise ( ( ) => { } ) ;
913900 if ( isInstanceOf ( Promise ) ( c ) ) {
914- type _ = AssertTrue < IsExact < typeof c , Promise < unknown > > > ;
901+ assertType < IsExact < typeof c , Promise < unknown > > > ( true ) ;
915902 }
916903 } ) ;
917904} ) ;
@@ -962,7 +949,7 @@ Deno.test("isLiteralOf<T>", async (t) => {
962949 const pred = "hello" ;
963950 const a : unknown = "hello" ;
964951 if ( isLiteralOf ( pred ) ( a ) ) {
965- type _ = AssertTrue < IsExact < typeof a , "hello" > > ;
952+ assertType < IsExact < typeof a , "hello" > > ( true ) ;
966953 }
967954 } ) ;
968955 await t . step ( "returns true on literal T" , ( ) => {
@@ -983,7 +970,7 @@ Deno.test("isLiteralOneOf<T>", async (t) => {
983970 const preds = [ "hello" , "world" ] as const ;
984971 const a : unknown = "hello" ;
985972 if ( isLiteralOneOf ( preds ) ( a ) ) {
986- type _ = AssertTrue < IsExact < typeof a , "hello" | "world" > > ;
973+ assertType < IsExact < typeof a , "hello" | "world" > > ( true ) ;
987974 }
988975 } ) ;
989976 await t . step ( "returns true on literal T" , ( ) => {
@@ -1005,7 +992,7 @@ Deno.test("isOneOf<T>", async (t) => {
1005992 const preds = [ isNumber , isString , isBoolean ] ;
1006993 const a : unknown = [ 0 , "a" , true ] ;
1007994 if ( isOneOf ( preds ) ( a ) ) {
1008- type _ = AssertTrue < IsExact < typeof a , number | string | boolean > > ;
995+ assertType < IsExact < typeof a , number | string | boolean > > ( true ) ;
1009996 }
1010997 } ) ;
1011998 await t . step ( "returns true on one of T" , ( ) => {
@@ -1039,7 +1026,7 @@ Deno.test("isAllOf<T>", async (t) => {
10391026 ] ;
10401027 const a : unknown = { a : 0 , b : "a" } ;
10411028 if ( isAllOf ( preds ) ( a ) ) {
1042- type _ = AssertTrue < IsExact < typeof a , { a : number ; b : string } > > ;
1029+ assertType < IsExact < typeof a , { a : number ; b : string } > > ( true ) ;
10431030 }
10441031 } ) ;
10451032 await t . step ( "returns true on all of T" , ( ) => {
@@ -1077,7 +1064,7 @@ Deno.test("isOptionalOf<T>", async (t) => {
10771064 await t . step ( "returns proper type predicate" , ( ) => {
10781065 const a : unknown = undefined ;
10791066 if ( isOptionalOf ( isNumber ) ( a ) ) {
1080- type _ = AssertTrue < IsExact < typeof a , number | undefined > > ;
1067+ assertType < IsExact < typeof a , number | undefined > > ( true ) ;
10811068 }
10821069 } ) ;
10831070 await t . step ( "with isString" , async ( t ) => {
0 commit comments