Skip to content

Commit 936444a

Browse files
committed
Add tests
1 parent fc2f16c commit 936444a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/cases/conformance/types/keyof/keyofAndIndexedAccess.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,20 @@ function f90<T extends S2, K extends keyof S2>(x1: S2[keyof S2], x2: T[keyof S2]
321321
x4.length;
322322
}
323323

324+
function f91<T, K extends keyof T>(x: T, y: T[keyof T], z: T[K]) {
325+
let a: {};
326+
a = x;
327+
a = y;
328+
a = z;
329+
}
330+
331+
function f92<T, K extends keyof T>(x: T, y: T[keyof T], z: T[K]) {
332+
let a: {} | null | undefined;
333+
a = x;
334+
a = y;
335+
a = z;
336+
}
337+
324338
// Repros from #12011
325339

326340
class Base {
@@ -594,3 +608,24 @@ type DynamicDBRecord<Flag extends string> = ({ dynamicField: number } | { dynami
594608
function getFlagsFromDynamicRecord<Flag extends string>(record: DynamicDBRecord<Flag>, flags: Flag[]) {
595609
return record[flags[0]];
596610
}
611+
612+
// Repro from #21368
613+
614+
interface I {
615+
foo: string;
616+
}
617+
618+
declare function take<T>(p: T): void;
619+
620+
function fn<T extends I, K extends keyof T>(o: T, k: K) {
621+
take<{} | null | undefined>(o[k]);
622+
take<any>(o[k]);
623+
}
624+
625+
// Repro from #23133
626+
627+
class Unbounded<T> {
628+
foo(x: T[keyof T]) {
629+
let y: {} | undefined | null = x;
630+
}
631+
}

0 commit comments

Comments
 (0)