File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
packages/dds/tree/src/test/util Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change 33 * Licensed under the MIT License.
44 */
55
6+ import { allowUnused } from "../../simple-tree/index.js" ;
67import type {
78 areSafelyAssignable ,
89 requireAssignableTo ,
@@ -89,4 +90,25 @@ import type {
8990 areSafelyAssignable < UnionToIntersection < { x : 1 | 2 } | { x : 2 | 3 } > , { x : 2 } >
9091 > ;
9192 type _check4 = requireTrue < areSafelyAssignable < UnionToIntersection < 1 > , 1 > > ;
93+
94+ // Check that arrays are preserved
95+ allowUnused <
96+ requireTrue < areSafelyAssignable < UnionToIntersection < readonly [ 1 | 2 ] > , readonly [ 1 | 2 ] > >
97+ > ( ) ;
98+
99+ // Check that intersections are preserved
100+ allowUnused <
101+ requireTrue <
102+ areSafelyAssignable < UnionToIntersection < { a : 1 } & { b : 2 } > , { a : 1 } & { b : 2 } >
103+ >
104+ > ( ) ;
105+
106+ // Check intersections of unions behave as if intersection was distributed over union
107+ {
108+ type intersectedUnion = ( { a : 1 } | { b : 2 } ) & { foo : 1 } ;
109+ type converted = UnionToIntersection < intersectedUnion > ;
110+ allowUnused <
111+ requireTrue < areSafelyAssignable < converted , { a : 1 } & { b : 2 } & { foo : 1 } > >
112+ > ( ) ;
113+ }
92114}
You can’t perform that action at this time.
0 commit comments