Skip to content

Commit 08c288d

Browse files
committed
Accept new baselines
1 parent 57ef618 commit 08c288d

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed

tests/baselines/reference/keyofAndIndexedAccess.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,15 @@ function f3<T, K extends Extract<keyof T, string>>(t: T, k: K, tk: T[K]): void {
565565
type Predicates<TaggedRecord> = {
566566
[T in keyof TaggedRecord]: (variant: TaggedRecord[keyof TaggedRecord]) => variant is TaggedRecord[T]
567567
}
568+
569+
// Repros from #23592
570+
571+
type Example<T extends { [K in keyof T]: { prop: any } }> = { [K in keyof T]: T[K]["prop"] };
572+
type Result = Example<{ a: { prop: string }; b: { prop: number } }>;
573+
574+
type Helper2<T> = { [K in keyof T]: Extract<T[K], { prop: any }> };
575+
type Example2<T> = { [K in keyof Helper2<T>]: Helper2<T>[K]["prop"] };
576+
type Result2 = Example2<{ 1: { prop: string }; 2: { prop: number } }>;
568577

569578

570579
//// [keyofAndIndexedAccess.js]
@@ -1212,3 +1221,34 @@ declare function f3<T, K extends Extract<keyof T, string>>(t: T, k: K, tk: T[K])
12121221
declare type Predicates<TaggedRecord> = {
12131222
[T in keyof TaggedRecord]: (variant: TaggedRecord[keyof TaggedRecord]) => variant is TaggedRecord[T];
12141223
};
1224+
declare type Example<T extends {
1225+
[K in keyof T]: {
1226+
prop: any;
1227+
};
1228+
}> = {
1229+
[K in keyof T]: T[K]["prop"];
1230+
};
1231+
declare type Result = Example<{
1232+
a: {
1233+
prop: string;
1234+
};
1235+
b: {
1236+
prop: number;
1237+
};
1238+
}>;
1239+
declare type Helper2<T> = {
1240+
[K in keyof T]: Extract<T[K], {
1241+
prop: any;
1242+
}>;
1243+
};
1244+
declare type Example2<T> = {
1245+
[K in keyof Helper2<T>]: Helper2<T>[K]["prop"];
1246+
};
1247+
declare type Result2 = Example2<{
1248+
1: {
1249+
prop: string;
1250+
};
1251+
2: {
1252+
prop: number;
1253+
};
1254+
}>;

tests/baselines/reference/keyofAndIndexedAccess.symbols

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,3 +2010,52 @@ type Predicates<TaggedRecord> = {
20102010
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 564, 3))
20112011
}
20122012

2013+
// Repros from #23592
2014+
2015+
type Example<T extends { [K in keyof T]: { prop: any } }> = { [K in keyof T]: T[K]["prop"] };
2016+
>Example : Symbol(Example, Decl(keyofAndIndexedAccess.ts, 565, 1))
2017+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 569, 13))
2018+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 569, 26))
2019+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 569, 13))
2020+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 569, 42))
2021+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 569, 63))
2022+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 569, 13))
2023+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 569, 13))
2024+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 569, 63))
2025+
2026+
type Result = Example<{ a: { prop: string }; b: { prop: number } }>;
2027+
>Result : Symbol(Result, Decl(keyofAndIndexedAccess.ts, 569, 93))
2028+
>Example : Symbol(Example, Decl(keyofAndIndexedAccess.ts, 565, 1))
2029+
>a : Symbol(a, Decl(keyofAndIndexedAccess.ts, 570, 23))
2030+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 570, 28))
2031+
>b : Symbol(b, Decl(keyofAndIndexedAccess.ts, 570, 44))
2032+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 570, 49))
2033+
2034+
type Helper2<T> = { [K in keyof T]: Extract<T[K], { prop: any }> };
2035+
>Helper2 : Symbol(Helper2, Decl(keyofAndIndexedAccess.ts, 570, 68))
2036+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 572, 13))
2037+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 572, 21))
2038+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 572, 13))
2039+
>Extract : Symbol(Extract, Decl(lib.d.ts, --, --))
2040+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 572, 13))
2041+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 572, 21))
2042+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 572, 51))
2043+
2044+
type Example2<T> = { [K in keyof Helper2<T>]: Helper2<T>[K]["prop"] };
2045+
>Example2 : Symbol(Example2, Decl(keyofAndIndexedAccess.ts, 572, 67))
2046+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 573, 14))
2047+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 573, 22))
2048+
>Helper2 : Symbol(Helper2, Decl(keyofAndIndexedAccess.ts, 570, 68))
2049+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 573, 14))
2050+
>Helper2 : Symbol(Helper2, Decl(keyofAndIndexedAccess.ts, 570, 68))
2051+
>T : Symbol(T, Decl(keyofAndIndexedAccess.ts, 573, 14))
2052+
>K : Symbol(K, Decl(keyofAndIndexedAccess.ts, 573, 22))
2053+
2054+
type Result2 = Example2<{ 1: { prop: string }; 2: { prop: number } }>;
2055+
>Result2 : Symbol(Result2, Decl(keyofAndIndexedAccess.ts, 573, 70))
2056+
>Example2 : Symbol(Example2, Decl(keyofAndIndexedAccess.ts, 572, 67))
2057+
>1 : Symbol(1, Decl(keyofAndIndexedAccess.ts, 574, 25))
2058+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 574, 30))
2059+
>2 : Symbol(2, Decl(keyofAndIndexedAccess.ts, 574, 46))
2060+
>prop : Symbol(prop, Decl(keyofAndIndexedAccess.ts, 574, 51))
2061+

tests/baselines/reference/keyofAndIndexedAccess.types

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2345,3 +2345,52 @@ type Predicates<TaggedRecord> = {
23452345
>T : T
23462346
}
23472347

2348+
// Repros from #23592
2349+
2350+
type Example<T extends { [K in keyof T]: { prop: any } }> = { [K in keyof T]: T[K]["prop"] };
2351+
>Example : Example<T>
2352+
>T : T
2353+
>K : K
2354+
>T : T
2355+
>prop : any
2356+
>K : K
2357+
>T : T
2358+
>T : T
2359+
>K : K
2360+
2361+
type Result = Example<{ a: { prop: string }; b: { prop: number } }>;
2362+
>Result : Example<{ a: { prop: string; }; b: { prop: number; }; }>
2363+
>Example : Example<T>
2364+
>a : { prop: string; }
2365+
>prop : string
2366+
>b : { prop: number; }
2367+
>prop : number
2368+
2369+
type Helper2<T> = { [K in keyof T]: Extract<T[K], { prop: any }> };
2370+
>Helper2 : Helper2<T>
2371+
>T : T
2372+
>K : K
2373+
>T : T
2374+
>Extract : Extract<T, U>
2375+
>T : T
2376+
>K : K
2377+
>prop : any
2378+
2379+
type Example2<T> = { [K in keyof Helper2<T>]: Helper2<T>[K]["prop"] };
2380+
>Example2 : Example2<T>
2381+
>T : T
2382+
>K : K
2383+
>Helper2 : Helper2<T>
2384+
>T : T
2385+
>Helper2 : Helper2<T>
2386+
>T : T
2387+
>K : K
2388+
2389+
type Result2 = Example2<{ 1: { prop: string }; 2: { prop: number } }>;
2390+
>Result2 : Example2<{ 1: { prop: string; }; 2: { prop: number; }; }>
2391+
>Example2 : Example2<T>
2392+
>1 : { prop: string; }
2393+
>prop : string
2394+
>2 : { prop: number; }
2395+
>prop : number
2396+

0 commit comments

Comments
 (0)