@@ -13,12 +13,37 @@ type Options2 = UnionToTuple<boolean | 1>;
1313expectType < Options2 [ number ] > ( { } as ( 1 | false | true ) ) ;
1414
1515// Different modifiers cases.
16- type DifferentModifiers = { a : 0 } | { readonly a : 0 } | { a ?: 0 } | { readonly a ?: 0 } ;
16+ type DifferentModifiers = { a : 0 } | { readonly a : 0 } ;
1717expectType < UnionToTuple < DifferentModifiers > [ number ] > ( { } as DifferentModifiers ) ;
18+ expectType < UnionToTuple < DifferentModifiers > [ 'length' ] > ( 2 ) ;
19+
20+ type ReversedDifferentModifiers = { readonly a : 0 } | { a : 0 } ;
21+ expectType < UnionToTuple < ReversedDifferentModifiers > [ number ] > ( { } as ReversedDifferentModifiers ) ;
22+ expectType < UnionToTuple < ReversedDifferentModifiers > [ 'length' ] > ( 2 ) ;
1823
1924// Super type cases.
2025type UnionSuperType0 = { a : string ; b : string } | { a : string } ;
2126expectType < UnionSuperType0 > ( { } as UnionToTuple < UnionSuperType0 > [ number ] ) ;
27+ expectType < UnionToTuple < UnionSuperType0 > [ 'length' ] > ( 2 ) ;
28+
29+ type ReversedUnionSuperType0 = { a : string } | { a : string ; b : string } ;
30+ expectType < ReversedUnionSuperType0 > ( { } as UnionToTuple < ReversedUnionSuperType0 > [ number ] ) ;
31+ expectType < UnionToTuple < ReversedUnionSuperType0 > [ 'length' ] > ( 2 ) ;
2232
23- type UnionSuperType1 = { a : 1 } | { b : 1 } | { [ x : string ] : number } ;
33+ type UnionSuperType1 = { a : 1 } | { [ x : string ] : number } ;
2434expectType < UnionSuperType1 > ( { } as UnionToTuple < UnionSuperType1 > [ number ] ) ;
35+ expectType < UnionToTuple < UnionSuperType1 > [ 'length' ] > ( 2 ) ;
36+
37+ type ReversedUnionSuperType1 = { [ x : string ] : number } | { a : 1 } ;
38+ expectType < ReversedUnionSuperType1 > ( { } as UnionToTuple < ReversedUnionSuperType1 > [ number ] ) ;
39+ expectType < UnionToTuple < ReversedUnionSuperType1 > [ 'length' ] > ( 2 ) ;
40+
41+ // Identical union cases.
42+ type UnionIdentical = { a : string } | { a : string } ; // eslint-disable-line @typescript-eslint/no-duplicate-type-constituents
43+ expectType < UnionToTuple < UnionIdentical > [ 'length' ] > ( 1 ) ;
44+
45+ type UnionIdenticalIntersection = { a : string } & { a : string } | { a : string } ; // eslint-disable-line @typescript-eslint/no-duplicate-type-constituents
46+ expectType < UnionToTuple < UnionIdenticalIntersection > [ 'length' ] > ( 1 ) ;
47+
48+ type ReversedUnionIdenticalIntersection = { a : string } | { a : string } & { a : string } ; // eslint-disable-line @typescript-eslint/no-duplicate-type-constituents
49+ expectType < UnionToTuple < ReversedUnionIdenticalIntersection > [ 'length' ] > ( 1 ) ;
0 commit comments