Skip to content

Commit 95bb156

Browse files
committed
Add tests
1 parent 4256be1 commit 95bb156

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// @strict: true
2+
// @declaration: true
3+
4+
type A = { a: string };
5+
type B = { b: string };
6+
7+
type T01 = keyof (A & B); // "a" | "b"
8+
type T02<T> = keyof (T & B); // "b" | keyof T
9+
type T03<U> = keyof (A & U); // "a" | keyof U
10+
type T04<T, U> = keyof (T & U); // keyof T | keyof U
11+
type T05 = T02<A>; // "a" | "b"
12+
type T06 = T03<B>; // "a" | "b"
13+
type T07 = T04<A, B>; // "a" | "b"
14+
15+
// Repros from #22291
16+
17+
type Example1<T extends string, U extends string> = keyof (Record<T, any> & Record<U, any>);
18+
type Result1 = Example1<'x', 'y'>; // "x" | "y"
19+
20+
type Result2 = keyof (Record<'x', any> & Record<'y', any>); // "x" | "y"
21+
22+
type Example3<T extends string> = keyof (Record<T, any>);
23+
type Result3 = Example3<'x' | 'y'>; // "x" | "y"
24+
25+
type Example4<T extends string, U extends string> = (Record<T, any> & Record<U, any>);
26+
type Result4 = keyof Example4<'x', 'y'>; // "x" | "y"
27+
28+
type Example5<T, U> = keyof (T & U);
29+
type Result5 = Example5<Record<'x', any>, Record<'y', any>>; // "x" | "y"

0 commit comments

Comments
 (0)