@@ -38,3 +38,40 @@ expectType<ArraySlice<[1, 2, 3, ...string[], 4, 5], 0>>([1, 2, 3, ...(null! as s
3838expectType < ArraySlice < [ 1 , 2 , 3 , ...string [ ] , 4 , 5 ] , 1 > > ( [ 2 , 3 , ...( null ! as string [ ] ) , 4 , 5 ] ) ;
3939expectType < ArraySlice < [ 1 , 2 , 3 , ...string [ ] , 4 , 5 ] , 3 > > ( [ ...( null ! as string [ ] ) , 4 , 5 ] ) ;
4040expectType < ArraySlice < [ 1 , 2 , 3 , ...string [ ] , 4 , 5 ] , 10 > > ( [ ...( null ! as string [ ] ) , 4 , 5 ] ) ;
41+
42+ // Unions
43+ // Array is union
44+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , 0 > > ( { } as [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] ) ; // Positive start, no end
45+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , - 2 > > ( { } as [ 1 , 2 ] | [ 'c' , 'd' ] ) ; // Negative start, no end
46+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , 0 , 2 > > ( { } as [ 0 , 1 ] | [ 'a' , 'b' ] ) ; // Positive start, positive end
47+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , - 2 , - 1 > > ( { } as [ 1 ] | [ 'c' ] ) ; // Negative start, negative end
48+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , - 3 , 2 > > ( { } as [ 0 , 1 ] | [ 'b' ] ) ; // Negative start, positive end
49+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , 1 , - 1 > > ( { } as [ 1 ] | [ 'b' , 'c' ] ) ; // Positive start, negative end
50+
51+ // Start is union
52+ expectType < ArraySlice < [ 0 , 1 , 2 , 3 ] , 1 | - 2 > > ( { } as [ 1 , 2 , 3 ] | [ 2 , 3 ] ) ; // Positive/Negative start, no end
53+ expectType < ArraySlice < [ 0 , 1 , 2 , 3 ] , 2 | - 3 , 3 > > ( { } as [ 2 ] | [ 1 , 2 ] ) ; // Positive/Negative start, positive end
54+ expectType < ArraySlice < [ 0 , 1 , 2 , 3 ] , 0 | - 2 , - 1 > > ( { } as [ 2 ] | [ 0 , 1 , 2 ] ) ; // Positive/Negative start, negative end
55+
56+ // End is union
57+ expectType < ArraySlice < [ 0 , 1 , 2 , 3 ] , 0 , 1 | - 2 > > ( { } as [ 0 ] | [ 0 , 1 ] ) ; // Positive start, positive/negative end
58+ expectType < ArraySlice < [ 0 , 1 , 2 , 3 ] , - 2 , 2 | - 1 > > ( { } as [ ] | [ 2 ] ) ; // Negative start, positive/negative end
59+
60+ // Array and start are unions
61+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , 1 | - 1 > > ( { } as [ 1 , 2 ] | [ 2 ] | [ 'b' , 'c' , 'd' ] | [ 'd' ] ) ; // Positive/Negative start, no end
62+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , 1 | - 2 , 2 > > ( { } as [ 1 ] | [ 'b' ] | [ ] ) ; // Positive/Negative start, positive end
63+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , 0 | - 2 , - 1 > > ( { } as [ 0 , 1 ] | [ 1 ] | [ 'a' , 'b' , 'c' ] | [ 'c' ] ) ; // Positive/Negative start, negative end
64+
65+ // Array and end are unions
66+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , 2 , 3 | - 1 > > ( { } as [ 2 ] | [ ] | [ 'c' ] ) ; // Positive start, positive/negative end
67+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , - 3 , 3 | - 2 > > ( { } as [ 0 , 1 , 2 ] | [ 0 ] | [ 'b' , 'c' ] | [ 'b' ] ) ; // Negative start, positive/negative end
68+
69+ // Start and end are unions
70+ expectType < ArraySlice < [ 0 , 1 , 2 , 3 ] , - 5 | 0 | 1 , - 2 | 0 | 3 > > ( // Positive/Negative start, positive/negative end
71+ { } as [ 0 , 1 ] | [ 0 , 1 , 2 ] | [ ] | [ 1 ] | [ 1 , 2 ] ,
72+ ) ;
73+
74+ // Array, start and end are unions
75+ expectType < ArraySlice < [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] , 1 | - 4 , 4 | - 1 > > ( // Positive/Negative start, positive/negative end
76+ { } as [ 1 ] | [ 1 , 2 ] | [ 0 , 1 ] | [ 0 , 1 , 2 ] | [ 'a' , 'b' , 'c' , 'd' ] | [ 'a' , 'b' , 'c' ] | [ 'b' , 'c' ] | [ 'b' , 'c' , 'd' ] ,
77+ ) ;
0 commit comments