@@ -18,26 +18,37 @@ expectType<StringSlice<string, 1, 2>>(null! as string);
1818
1919// Unions
2020// String is union
21- expectType < StringSlice < 'abcd' | '0123456789' > > ( { } as 'abcd' | '0123456789' ) ;
22- expectType < StringSlice < 'abcd' | '0123456789' , 0 , 2 > > ( { } as 'ab' | '01' ) ;
21+ expectType < StringSlice < '012' | 'abcd' , 0 > > ( { } as '012' | 'abcd' ) ; // Positive start, no end
22+ expectType < StringSlice < '012' | 'abcd' , - 2 > > ( { } as '12' | 'cd' ) ; // Negative start, no end
23+ expectType < StringSlice < '012' | 'abcd' , 0 , 2 > > ( { } as '01' | 'ab' ) ; // Positive start, positive end
24+ expectType < StringSlice < '012' | 'abcd' , - 2 , - 1 > > ( { } as '1' | 'c' ) ; // Negative start, negative end
25+ expectType < StringSlice < '012' | 'abcd' , - 3 , 2 > > ( { } as '01' | 'b' ) ; // Negative start, positive end
26+ expectType < StringSlice < '012' | 'abcd' , 1 , - 1 > > ( { } as '1' | 'bc' ) ; // Positive start, negative end
2327
2428// Start is union
25- expectType < StringSlice < 'abcd' , 1 | 3 > > ( { } as 'bcd' | 'd' ) ;
26- expectType < StringSlice < 'abcd' , 0 | 2 , 3 > > ( { } as 'abc' | 'c' ) ;
29+ expectType < StringSlice < '0123' , 1 | - 2 > > ( { } as '123' | '23' ) ; // Positive/Negative start, no end
30+ expectType < StringSlice < '0123' , 2 | - 3 , 3 > > ( { } as '2' | '12' ) ; // Positive/Negative start, positive end
31+ expectType < StringSlice < '0123' , 0 | - 2 , - 1 > > ( { } as '2' | '012' ) ; // Positive/Negative start, negative end
2732
2833// End is union
29- expectType < StringSlice < 'abcd' , 1 , 2 | 3 > > ( { } as 'b' | 'bc' ) ;
34+ expectType < StringSlice < '0123' , 0 , 1 | - 2 > > ( { } as '0' | '01' ) ; // Positive start, positive/negative end
35+ expectType < StringSlice < '0123' , - 2 , 2 | - 1 > > ( { } as '' | '2' ) ; // Negative start, positive/negative end
3036
31- // String and start are unions
32- expectType < StringSlice < 'abcd' | '0123456789' , 1 | 2 > > ( { } as 'bcd' | 'cd' | '123456789' | '23456789' ) ;
37+ // Array and start are unions
38+ expectType < StringSlice < '012' | 'abcd' , 1 | - 1 > > ( { } as '12' | '2' | 'bcd' | 'd' ) ; // Positive/Negative start, no end
39+ expectType < StringSlice < '012' | 'abcd' , 1 | - 2 , 2 > > ( { } as '1' | 'b' | '' ) ; // Positive/Negative start, positive end
40+ expectType < StringSlice < '012' | 'abcd' , 0 | - 2 , - 1 > > ( { } as '01' | '1' | 'abc' | 'c' ) ; // Positive/Negative start, negative end
3341
34- // String and end are unions
35- expectType < StringSlice < 'abcd' | '0123456789' , 1 , 2 | 3 > > ( { } as 'b' | 'bc' | '1' | '12' ) ;
42+ // Array and end are unions
43+ expectType < StringSlice < '012' | 'abcd' , 2 , 3 | - 1 > > ( { } as '2' | '' | 'c' ) ; // Positive start, positive/negative end
44+ expectType < StringSlice < '012' | 'abcd' , - 3 , 3 | - 2 > > ( { } as '012' | '0' | 'bc' | 'b' ) ; // Negative start, positive/negative end
3645
3746// Start and end are unions
38- expectType < StringSlice < 'abcd' , 0 | 1 , 2 | 3 > > ( { } as 'ab' | 'abc' | 'b' | 'bc' ) ;
47+ expectType < StringSlice < '0123' , - 5 | 0 | 1 , - 2 | 0 | 3 > > ( // Positive/Negative start, positive/negative end
48+ { } as '01' | '012' | '' | '1' | '12' ,
49+ ) ;
3950
40- // String , start and end are unions
41- expectType < StringSlice < 'abcd ' | '0123456789 ' , 0 | 1 , 2 | 3 > > (
42- { } as 'ab ' | 'abc ' | 'b ' | 'bc ' | '01 ' | '012 ' | '1 ' | '12 ' ,
51+ // Array , start and end are unions
52+ expectType < StringSlice < '012 ' | 'abcd ' , 1 | - 4 , 4 | - 1 > > ( // Positive/Negative start, positive/negative end
53+ { } as '1 ' | '12 ' | '01 ' | '012 ' | 'abcd ' | 'abc ' | 'bc ' | 'bcd ' ,
4354) ;
0 commit comments