Skip to content

Commit 8861913

Browse files
committed
Accept new baselines
1 parent 95bb156 commit 8861913

File tree

3 files changed

+266
-0
lines changed

3 files changed

+266
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
//// [keyofIntersection.ts]
2+
type A = { a: string };
3+
type B = { b: string };
4+
5+
type T01 = keyof (A & B); // "a" | "b"
6+
type T02<T> = keyof (T & B); // "b" | keyof T
7+
type T03<U> = keyof (A & U); // "a" | keyof U
8+
type T04<T, U> = keyof (T & U); // keyof T | keyof U
9+
type T05 = T02<A>; // "a" | "b"
10+
type T06 = T03<B>; // "a" | "b"
11+
type T07 = T04<A, B>; // "a" | "b"
12+
13+
// Repros from #22291
14+
15+
type Example1<T extends string, U extends string> = keyof (Record<T, any> & Record<U, any>);
16+
type Result1 = Example1<'x', 'y'>; // "x" | "y"
17+
18+
type Result2 = keyof (Record<'x', any> & Record<'y', any>); // "x" | "y"
19+
20+
type Example3<T extends string> = keyof (Record<T, any>);
21+
type Result3 = Example3<'x' | 'y'>; // "x" | "y"
22+
23+
type Example4<T extends string, U extends string> = (Record<T, any> & Record<U, any>);
24+
type Result4 = keyof Example4<'x', 'y'>; // "x" | "y"
25+
26+
type Example5<T, U> = keyof (T & U);
27+
type Result5 = Example5<Record<'x', any>, Record<'y', any>>; // "x" | "y"
28+
29+
30+
//// [keyofIntersection.js]
31+
"use strict";
32+
33+
34+
//// [keyofIntersection.d.ts]
35+
declare type A = {
36+
a: string;
37+
};
38+
declare type B = {
39+
b: string;
40+
};
41+
declare type T01 = keyof (A & B);
42+
declare type T02<T> = keyof (T & B);
43+
declare type T03<U> = keyof (A & U);
44+
declare type T04<T, U> = keyof (T & U);
45+
declare type T05 = T02<A>;
46+
declare type T06 = T03<B>;
47+
declare type T07 = T04<A, B>;
48+
declare type Example1<T extends string, U extends string> = keyof (Record<T, any> & Record<U, any>);
49+
declare type Result1 = Example1<'x', 'y'>;
50+
declare type Result2 = keyof (Record<'x', any> & Record<'y', any>);
51+
declare type Example3<T extends string> = keyof (Record<T, any>);
52+
declare type Result3 = Example3<'x' | 'y'>;
53+
declare type Example4<T extends string, U extends string> = (Record<T, any> & Record<U, any>);
54+
declare type Result4 = keyof Example4<'x', 'y'>;
55+
declare type Example5<T, U> = keyof (T & U);
56+
declare type Result5 = Example5<Record<'x', any>, Record<'y', any>>;
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
=== tests/cases/conformance/types/keyof/keyofIntersection.ts ===
2+
type A = { a: string };
3+
>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0))
4+
>a : Symbol(a, Decl(keyofIntersection.ts, 0, 10))
5+
6+
type B = { b: string };
7+
>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23))
8+
>b : Symbol(b, Decl(keyofIntersection.ts, 1, 10))
9+
10+
type T01 = keyof (A & B); // "a" | "b"
11+
>T01 : Symbol(T01, Decl(keyofIntersection.ts, 1, 23))
12+
>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0))
13+
>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23))
14+
15+
type T02<T> = keyof (T & B); // "b" | keyof T
16+
>T02 : Symbol(T02, Decl(keyofIntersection.ts, 3, 25))
17+
>T : Symbol(T, Decl(keyofIntersection.ts, 4, 9))
18+
>T : Symbol(T, Decl(keyofIntersection.ts, 4, 9))
19+
>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23))
20+
21+
type T03<U> = keyof (A & U); // "a" | keyof U
22+
>T03 : Symbol(T03, Decl(keyofIntersection.ts, 4, 28))
23+
>U : Symbol(U, Decl(keyofIntersection.ts, 5, 9))
24+
>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0))
25+
>U : Symbol(U, Decl(keyofIntersection.ts, 5, 9))
26+
27+
type T04<T, U> = keyof (T & U); // keyof T | keyof U
28+
>T04 : Symbol(T04, Decl(keyofIntersection.ts, 5, 28))
29+
>T : Symbol(T, Decl(keyofIntersection.ts, 6, 9))
30+
>U : Symbol(U, Decl(keyofIntersection.ts, 6, 11))
31+
>T : Symbol(T, Decl(keyofIntersection.ts, 6, 9))
32+
>U : Symbol(U, Decl(keyofIntersection.ts, 6, 11))
33+
34+
type T05 = T02<A>; // "a" | "b"
35+
>T05 : Symbol(T05, Decl(keyofIntersection.ts, 6, 31))
36+
>T02 : Symbol(T02, Decl(keyofIntersection.ts, 3, 25))
37+
>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0))
38+
39+
type T06 = T03<B>; // "a" | "b"
40+
>T06 : Symbol(T06, Decl(keyofIntersection.ts, 7, 18))
41+
>T03 : Symbol(T03, Decl(keyofIntersection.ts, 4, 28))
42+
>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23))
43+
44+
type T07 = T04<A, B>; // "a" | "b"
45+
>T07 : Symbol(T07, Decl(keyofIntersection.ts, 8, 18))
46+
>T04 : Symbol(T04, Decl(keyofIntersection.ts, 5, 28))
47+
>A : Symbol(A, Decl(keyofIntersection.ts, 0, 0))
48+
>B : Symbol(B, Decl(keyofIntersection.ts, 0, 23))
49+
50+
// Repros from #22291
51+
52+
type Example1<T extends string, U extends string> = keyof (Record<T, any> & Record<U, any>);
53+
>Example1 : Symbol(Example1, Decl(keyofIntersection.ts, 9, 21))
54+
>T : Symbol(T, Decl(keyofIntersection.ts, 13, 14))
55+
>U : Symbol(U, Decl(keyofIntersection.ts, 13, 31))
56+
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
57+
>T : Symbol(T, Decl(keyofIntersection.ts, 13, 14))
58+
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
59+
>U : Symbol(U, Decl(keyofIntersection.ts, 13, 31))
60+
61+
type Result1 = Example1<'x', 'y'>; // "x" | "y"
62+
>Result1 : Symbol(Result1, Decl(keyofIntersection.ts, 13, 92))
63+
>Example1 : Symbol(Example1, Decl(keyofIntersection.ts, 9, 21))
64+
65+
type Result2 = keyof (Record<'x', any> & Record<'y', any>); // "x" | "y"
66+
>Result2 : Symbol(Result2, Decl(keyofIntersection.ts, 14, 34))
67+
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
68+
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
69+
70+
type Example3<T extends string> = keyof (Record<T, any>);
71+
>Example3 : Symbol(Example3, Decl(keyofIntersection.ts, 16, 59))
72+
>T : Symbol(T, Decl(keyofIntersection.ts, 18, 14))
73+
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
74+
>T : Symbol(T, Decl(keyofIntersection.ts, 18, 14))
75+
76+
type Result3 = Example3<'x' | 'y'>; // "x" | "y"
77+
>Result3 : Symbol(Result3, Decl(keyofIntersection.ts, 18, 57))
78+
>Example3 : Symbol(Example3, Decl(keyofIntersection.ts, 16, 59))
79+
80+
type Example4<T extends string, U extends string> = (Record<T, any> & Record<U, any>);
81+
>Example4 : Symbol(Example4, Decl(keyofIntersection.ts, 19, 35))
82+
>T : Symbol(T, Decl(keyofIntersection.ts, 21, 14))
83+
>U : Symbol(U, Decl(keyofIntersection.ts, 21, 31))
84+
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
85+
>T : Symbol(T, Decl(keyofIntersection.ts, 21, 14))
86+
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
87+
>U : Symbol(U, Decl(keyofIntersection.ts, 21, 31))
88+
89+
type Result4 = keyof Example4<'x', 'y'>; // "x" | "y"
90+
>Result4 : Symbol(Result4, Decl(keyofIntersection.ts, 21, 86))
91+
>Example4 : Symbol(Example4, Decl(keyofIntersection.ts, 19, 35))
92+
93+
type Example5<T, U> = keyof (T & U);
94+
>Example5 : Symbol(Example5, Decl(keyofIntersection.ts, 22, 40))
95+
>T : Symbol(T, Decl(keyofIntersection.ts, 24, 14))
96+
>U : Symbol(U, Decl(keyofIntersection.ts, 24, 16))
97+
>T : Symbol(T, Decl(keyofIntersection.ts, 24, 14))
98+
>U : Symbol(U, Decl(keyofIntersection.ts, 24, 16))
99+
100+
type Result5 = Example5<Record<'x', any>, Record<'y', any>>; // "x" | "y"
101+
>Result5 : Symbol(Result5, Decl(keyofIntersection.ts, 24, 36))
102+
>Example5 : Symbol(Example5, Decl(keyofIntersection.ts, 22, 40))
103+
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
104+
>Record : Symbol(Record, Decl(lib.d.ts, --, --))
105+
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
=== tests/cases/conformance/types/keyof/keyofIntersection.ts ===
2+
type A = { a: string };
3+
>A : A
4+
>a : string
5+
6+
type B = { b: string };
7+
>B : B
8+
>b : string
9+
10+
type T01 = keyof (A & B); // "a" | "b"
11+
>T01 : "b" | "a"
12+
>A : A
13+
>B : B
14+
15+
type T02<T> = keyof (T & B); // "b" | keyof T
16+
>T02 : keyof T | "b"
17+
>T : T
18+
>T : T
19+
>B : B
20+
21+
type T03<U> = keyof (A & U); // "a" | keyof U
22+
>T03 : "a" | keyof U
23+
>U : U
24+
>A : A
25+
>U : U
26+
27+
type T04<T, U> = keyof (T & U); // keyof T | keyof U
28+
>T04 : keyof T | keyof U
29+
>T : T
30+
>U : U
31+
>T : T
32+
>U : U
33+
34+
type T05 = T02<A>; // "a" | "b"
35+
>T05 : "b" | "a"
36+
>T02 : keyof T | "b"
37+
>A : A
38+
39+
type T06 = T03<B>; // "a" | "b"
40+
>T06 : "b" | "a"
41+
>T03 : "a" | keyof U
42+
>B : B
43+
44+
type T07 = T04<A, B>; // "a" | "b"
45+
>T07 : "b" | "a"
46+
>T04 : keyof T | keyof U
47+
>A : A
48+
>B : B
49+
50+
// Repros from #22291
51+
52+
type Example1<T extends string, U extends string> = keyof (Record<T, any> & Record<U, any>);
53+
>Example1 : T | U
54+
>T : T
55+
>U : U
56+
>Record : Record<K, T>
57+
>T : T
58+
>Record : Record<K, T>
59+
>U : U
60+
61+
type Result1 = Example1<'x', 'y'>; // "x" | "y"
62+
>Result1 : "x" | "y"
63+
>Example1 : T | U
64+
65+
type Result2 = keyof (Record<'x', any> & Record<'y', any>); // "x" | "y"
66+
>Result2 : "x" | "y"
67+
>Record : Record<K, T>
68+
>Record : Record<K, T>
69+
70+
type Example3<T extends string> = keyof (Record<T, any>);
71+
>Example3 : T
72+
>T : T
73+
>Record : Record<K, T>
74+
>T : T
75+
76+
type Result3 = Example3<'x' | 'y'>; // "x" | "y"
77+
>Result3 : "x" | "y"
78+
>Example3 : T
79+
80+
type Example4<T extends string, U extends string> = (Record<T, any> & Record<U, any>);
81+
>Example4 : Record<T, any> & Record<U, any>
82+
>T : T
83+
>U : U
84+
>Record : Record<K, T>
85+
>T : T
86+
>Record : Record<K, T>
87+
>U : U
88+
89+
type Result4 = keyof Example4<'x', 'y'>; // "x" | "y"
90+
>Result4 : "x" | "y"
91+
>Example4 : Record<T, any> & Record<U, any>
92+
93+
type Example5<T, U> = keyof (T & U);
94+
>Example5 : keyof T | keyof U
95+
>T : T
96+
>U : U
97+
>T : T
98+
>U : U
99+
100+
type Result5 = Example5<Record<'x', any>, Record<'y', any>>; // "x" | "y"
101+
>Result5 : "x" | "y"
102+
>Example5 : keyof T | keyof U
103+
>Record : Record<K, T>
104+
>Record : Record<K, T>
105+

0 commit comments

Comments
 (0)