@@ -8,6 +8,7 @@ import {e,t} from "./base";
88declare const regexp1 : TypedRegExp < [ "$1" , "$2" ] , { some ?:"test group" , other ?:"more" } , "gdi" | "dim" > ;
99declare const regexp2 : TypedRegExp < [ "2-$1" , "2-$2" ] , undefined > ;
1010
11+ // --- TypedRegExp ---
1112t ( regexp1 . dotAll ) < true > ( ) ;
1213t ( regexp1 . global ) < true | false > ( ) ;
1314t ( regexp1 . ignoreCase ) < true > ( ) ;
@@ -25,6 +26,7 @@ t(regexp1[Symbol.replace]("",""))<string>();
2526t ( regexp1 [ Symbol . replace ] ( "" , ( _m : string , _g1 : "$1" , _g2 : "$2" , _i : number , _s : string , _g : { some ?: "test group" , other ?: "more" } ) => "" ) ) < string > ( ) ;
2627t ( regexp2 [ Symbol . replace ] ( "" , ( _m : string , _g1 : "2-$1" , _g2 : "2-$2" , _i : number , _s : string ) => "" ) ) < string > ( ) ;
2728
29+ // --- TypedRegExpMatchArray ---
2830const match = "" . match ( regexp1 ) ;
2931
3032t ( match ) < TypedRegExpMatchArray < [ "$1" , "$2" ] , { some ?:"test group" , other ?:"more" } > | null > ( ) ;
@@ -44,6 +46,16 @@ if (match) {
4446 t ( match ) < null > ( ) ;
4547}
4648
49+ declare const match2 : TypedRegExpMatchArray < [ ] , undefined | { some ?:"test group" , other ?:"more" } > ;
50+
51+ t ( match2 . groups ) < { some ?:"test group" , other ?:"more" } | undefined > ( ) ; // TODO fix never is ignored
52+ if ( match2 . groups ) {
53+ t ( match2 . groups ) < { some ?:"test group" , other ?:"more" } > ( ) ;
54+ } else {
55+ t ( match2 . groups ) < undefined > ( ) ;
56+ }
57+
58+ // --- TypedRegExpExecArray ---
4759const exec = regexp2 . exec ( "exec string" ) ;
4860
4961t ( exec ) < TypedRegExpExecArray < [ "2-$1" , "2-$2" ] , undefined , "exec string" > | null > ( ) ;
@@ -61,12 +73,3 @@ if (exec) {
6173} else {
6274 t ( exec ) < null > ( ) ;
6375}
64-
65- declare const match2 : TypedRegExpMatchArray < [ ] , undefined | { some ?:"test group" , other ?:"more" } > ;
66-
67- t ( match2 . groups ) < { some ?:"test group" , other ?:"more" } | undefined > ( ) ; // TODO fix never is ignored
68- if ( match2 . groups ) {
69- t ( match2 . groups ) < { some ?:"test group" , other ?:"more" } > ( ) ;
70- } else {
71- t ( match2 . groups ) < undefined > ( ) ;
72- }
0 commit comments